Skip to content

[BUG] [v0.0.7] app-server /agents API writes to .factory/agents, so standard loaders never discover created agents #53528

@DDDDDGCSM

Description

@DDDDDGCSM

Project

cortex

Description

The app-server custom agent API uses a different storage layout from the rest of Cortex:

  • POST /api/v1/agents with scope=project writes to .factory/agents
  • POST /api/v1/agents with scope=user writes to ~/.factory/agents

But the standard agent loaders and UIs do not scan .factory/agents at all. They scan:

  • .agents
  • .agent
  • .cortex/agents
  • ~/.cortex/agents
  • ~/.config/cortex/agents

So an agent created through the app-server API can be written successfully but still remain invisible to the standard loader used by the rest of Cortex.

Error Message

No explicit error is shown. The bug is a silent storage mismatch: create succeeds, but discovery never finds the created agent.

Debug Logs

CARGO_HOME=/tmp/cargo-home-rsproxy cargo test -p cortex-app-server project_agent_created_via_api_is_not_discoverable_by_standard_loader --manifest-path /tmp/cortex-upstream/Cargo.toml -- --test-threads=1 --nocapture

running 1 test
factory_path=/tmp/.../.factory/agents/factory-only-agent.md
loader_paths=[project/.agents, project/.agent, project/.cortex/agents, HOME/.cortex/agents, XDG_CONFIG_HOME/cortex/agents]
loaded_names=[]
ok

System Information

macOS Darwin 25.x (Apple Silicon)
Cortex v0.0.7 source checkout
Rust toolchain: cargo 1.95.0 / rustc 1.95.0

Screenshots

Cortex app-server agent path mismatch evidence

Steps to Reproduce

  1. Use the app-server custom agent creation path with scope=project.
  2. Observe the created file is written under .factory/agents/<name>.md.
  3. Run the standard custom agent loader for the same project root.
  4. Observe that the loader only scans .agents, .agent, .cortex/agents, ~/.cortex/agents, and ~/.config/cortex/agents.
  5. The agent that was just created by the API is not discovered.

The targeted proof command above demonstrates the mismatch directly and prints both:

  • the path where the app-server wrote the new agent
  • the exact directories searched by the standard loader

Expected Behavior

Agents created via the app-server API should be stored in a directory that the standard Cortex agent loaders also scan, so the created agent becomes discoverable and usable immediately across the rest of the product.

Actual Behavior

The API writes custom agents to .factory/agents / ~/.factory/agents, but the standard loaders never scan those directories. The created agent exists on disk but is effectively invisible to the rest of Cortex.

Additional Context

Relevant code paths:

  • src/cortex-app-server/src/api/agents.rs
    • project agents: .factory/agents
    • user agents: ~/.factory/agents
  • src/cortex-agents/src/custom/loader.rs
    • scans .agents, .agent, .cortex/agents, ~/.cortex/agents, ~/.config/cortex/agents
  • src/cortex-tui/src/interactive/builders/agents.rs
    • uses .cortex/agents and ~/.config/cortex/agents
  • src/cortex-commands/src/builtin/agents_cmd.rs
    • documents .cortex/agents/ and ~/.config/cortex/agents/

This is not just a path-style inconsistency. It creates a functional mismatch where app-server-created agents are not discoverable by the standard loader and therefore do not participate in the normal custom-agent flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideIssues related to IDEvalidValid issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions