Skip to content

fix(output): global prompt must not be emitted to project memory files #389

@TrueNine

Description

@TrueNine

Problem

Fixes #379 introduced the wrong attribution for global_memory / global_prompt output.

Issue #379 described missing AGENTS_OUTPUT_ADAPTOR handling, but the follow-up implementation interpreted that as: when AgentsOutputAdaptor is registered, project-level memory files should switch to global_memory.content.

That is incorrect. aindex/global.mdx is a user/global prompt source, not a project prompt source. It must not be written into project roots such as:

  • <project>/AGENTS.md
  • <project>/CLAUDE.md
  • <project>/.opencode/AGENTS.md

Expected behavior

global_prompt / aindex/global.mdx should only be emitted to each tool's global/user-level memory location:

  1. Codex: ~/.codex/AGENTS.md
  2. Claude Code: ~/.claude/CLAUDE.md
  3. OpenCode: ~/.config/opencode/AGENTS.md

Project-level files should continue to use project/workspace memory prompts, for example aindex/app/<project>/agt.mdx, child agt.mdx, or workspace prompt behavior where explicitly designed.

Incorrect current behavior

The current code paths explicitly write context.global_memory.content into project-level outputs when AgentsOutputAdaptor is registered:

  • sdk/src/domain/output_plans/codex_output_plan.rs
    • Writes global_memory.content to <project>/AGENTS.md
  • sdk/src/domain/output_plans/claude_code_output_plan.rs
    • Writes global_memory.content to <project>/CLAUDE.md
  • sdk/src/domain/output_plans/opencode_output_plan.rs
    • Writes global_memory.content to <project>/.opencode/AGENTS.md

The inline comments saying Fixes #379 are therefore misleading and should be corrected or removed.

Suggested fix

  • Keep global prompt output only at tool-global paths:
    • Codex ~/.codex/AGENTS.md
    • Claude ~/.claude/CLAUDE.md
    • OpenCode ~/.config/opencode/AGENTS.md
  • Stop writing global_memory.content into project-level memory files.
  • Rework the AgentsOutputAdaptor interaction so enabling agentsMd does not cause other tool output plans to replace project memory with global memory.
  • Add regression tests proving aindex/global.mdx is absent from project-level AGENTS.md, CLAUDE.md, and .opencode/AGENTS.md.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoutput-planOutput plan logicrustRust SDK/CLI/MCP code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions