Skip to content

Settings UI writes IDENTITY.md and SOUL.md to root instead of agents/main/ workspace #376

@lijunle-bot

Description

@lijunle-bot

Bug

When updating the main agent identity or soul via the Settings UI, the files are written to data_dir/IDENTITY.md and data_dir/SOUL.md (root) instead of data_dir/agents/main/IDENTITY.md and data_dir/agents/main/SOUL.md.

However, both load_identity_for_agent("main") and load_soul_for_agent("main") check agents/main/ first and only fall back to root. So if the agent-level files already exist, the settings updates are silently ignored at runtime.

Root Cause

IDENTITY.md

The call chain for the main agent identity update:

  1. Settings UI (identity-utils.js) calls updateIdentity(fields, { agentId: "main" })
  2. This sends RPC agents.identity.update with agent_id: "main"
  3. If that fails (method not found fallback), it sends agent.identity.update without agent_id
  4. agent.identity.update handler (services.rs:322-330): for main agent, delegates to onboarding.identity_update()
  5. onboarding.identity_update() (service.rs:271): calls moltis_config::save_identity(&identity) — writes to root data_dir/IDENTITY.md

But load_identity_for_agent("main") (loader.rs:374-380) reads from agents/main/IDENTITY.md first and only falls back to root:

pub fn load_identity_for_agent(agent_id: &str) -> Option<AgentIdentity> {
    if agent_id == "main" {
        let main_path = agent_workspace_dir("main").join("IDENTITY.md");
        if let Some(identity) = load_identity_from_path(&main_path) {
            return Some(identity);
        }
        return load_identity();  // fallback to root
    }
    // ...
}

SOUL.md (same pattern)

The save path for soul updates:

  1. Settings UI calls agent.identity.update_soul
  2. identity_update_soul() (service.rs:295): calls moltis_config::save_soul() — writes to root data_dir/SOUL.md

But load_soul_for_agent("main") (loader.rs:515-523) reads from agents/main/SOUL.md first:

pub fn load_soul_for_agent(agent_id: &str) -> Option<String> {
    if agent_id == "main" {
        let main_path = agent_workspace_dir("main").join("SOUL.md");
        if let Some(soul) = load_workspace_markdown(main_path) {
            return Some(soul);
        }
        return load_soul();  // fallback to root
    }
    // ...
}

Meanwhile, save_soul() writes to soul_path() which is data_dir()/SOUL.md (root).

Consequence

  • Both root IDENTITY.md and SOUL.md should not be primary write targets for the main agent
  • If agents/main/ versions exist, any changes through onboarding or the settings page are invisible
  • The UI string "Saved to IDENTITY.md in your workspace root" is misleading

Suggested Fix

IDENTITY.md

In crates/onboarding/src/service.rs, both at line 110 and line 271, replace:

moltis_config::save_identity(&ws.identity)

with:

moltis_config::save_identity_for_agent("main", &ws.identity)

SOUL.md

In crates/onboarding/src/service.rs line 295, the identity_update_soul() method should call a new save_soul_for_agent("main", soul) function (analogous to save_identity_for_agent) that writes to agents/main/SOUL.md instead of root.

Alternatively, save_soul() could be updated to always write to the agent workspace when the agent_id is known.

The root files can remain as legacy fallbacks for installations that do not yet have agents/main/ versions.

Steps to Reproduce

  1. Ensure data_dir/agents/main/IDENTITY.md and data_dir/agents/main/SOUL.md exist
  2. Edit agent name or soul text via Settings UI
  3. Observe root-level files are updated, but agent-level files are unchanged
  4. Runtime continues using the old agent-level files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions