Skip to content

Ground live agent answers in project context (AGENTS.md/CLAUDE.md)#263

Merged
alexkroman merged 4 commits into
mainfrom
claude/ecstatic-gauss-vb39de
Jun 23, 2026
Merged

Ground live agent answers in project context (AGENTS.md/CLAUDE.md)#263
alexkroman merged 4 commits into
mainfrom
claude/ecstatic-gauss-vb39de

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

The live agent now reads the launch directory's AGENTS.md or CLAUDE.md into its system prompt, grounding spoken answers in the project it's run from — following the same convention coding agents use.

Changes

  • New module aai_cli/agent_cascade/project_context.py: Loads project instruction files with deduplication (identical content included once) and truncation (capped at 16KB so oversized files don't crowd the conversation). Reads AGENTS.md first (higher precedence), then CLAUDE.md, defaulting to the current working directory.

  • Updated aai_cli/agent_cascade/prompt.py: build_system_prompt() now accepts an optional project_context parameter and appends it as project background when present, introduced with a heading so the model treats it as grounding rather than another instruction to recite.

  • Updated aai_cli/agent_cascade/brain.py: Threads project_context from the cascade config into the system prompt when building the agent graph.

  • Updated aai_cli/agent_cascade/config.py: Added project_context field to CascadeConfig to carry the loaded instruction file through the cascade pipeline.

  • Updated aai_cli/commands/agent_cascade/_exec.py: run_agent_cascade() calls load_project_context() and passes it to the config before building the cascade engine.

  • Updated REFERENCE.md: Documented the new behavior, noting that it's independent of --files and not reflected in --show-code output.

  • Comprehensive test coverage:

    • tests/test_agent_cascade_project_context.py (new): Tests the loader's file reading, deduplication, truncation, and edge cases.
    • tests/test_agent_cascade_prompt.py: Tests system prompt integration with and without project context.
    • tests/test_agent_cascade_brain.py: Tests that project context flows into the built graph's system prompt.

Implementation details

  • Identical file content (e.g., CLAUDE.md symlinked to AGENTS.md) is deduplicated on content, not filename, so it works across platforms without depending on symlink support.
  • Whitespace-only files are treated as absent (return None, not an empty heading).
  • The truncation marker [project context truncated] signals to the model when it's seeing only the head of an oversized file.
  • The feature is always active when instruction files are present; it's not gated by --files or any other flag.

https://claude.ai/code/session_01QegBRMt1QU2LRvbEMyCdiT

`assembly live` now reads the launch directory's AGENTS.md/CLAUDE.md into the
deepagents brain's system prompt — the same project-grounding convention coding
agents follow — so spoken answers reflect the project it's run from.

The loader (agent_cascade/project_context.py) prefers AGENTS.md, de-duplicates
identical content (a CLAUDE.md symlinked to AGENTS.md), and caps the injected
text so an oversized file can't crowd out the conversation. It's read at the
command boundary into CascadeConfig.project_context and threaded through
build_graph into build_system_prompt, keeping the brain hermetic. This is
independent of --files and is not reflected in --show-code output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QegBRMt1QU2LRvbEMyCdiT
@alexkroman alexkroman enabled auto-merge June 23, 2026 14:03
Comment thread aai_cli/agent_cascade/project_context.py Outdated
_truncate sliced to MAX_CONTEXT_CHARS then appended the marker, so a truncated
result was longer than the advertised cap. Reserve room for the marker in the
slice so MAX_CONTEXT_CHARS is a true upper bound, matching the docstring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QegBRMt1QU2LRvbEMyCdiT
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 23, 2026
…-vb39de

# Conflicts:
#	REFERENCE.md
#	aai_cli/AGENTS.md
@alexkroman alexkroman enabled auto-merge June 23, 2026 15:43
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 23, 2026
@alexkroman alexkroman enabled auto-merge June 23, 2026 15:52
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit fb4e97c Jun 23, 2026
20 checks passed
@alexkroman alexkroman deleted the claude/ecstatic-gauss-vb39de branch June 23, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants