Ground live agent answers in project context (AGENTS.md/CLAUDE.md)#263
Merged
Conversation
`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
_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
…-vb39de # Conflicts: # REFERENCE.md # aai_cli/AGENTS.md
…-vb39de # Conflicts: # aai_cli/AGENTS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The live agent now reads the launch directory's
AGENTS.mdorCLAUDE.mdinto 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). ReadsAGENTS.mdfirst (higher precedence), thenCLAUDE.md, defaulting to the current working directory.Updated
aai_cli/agent_cascade/prompt.py:build_system_prompt()now accepts an optionalproject_contextparameter 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: Threadsproject_contextfrom the cascade config into the system prompt when building the agent graph.Updated
aai_cli/agent_cascade/config.py: Addedproject_contextfield toCascadeConfigto carry the loaded instruction file through the cascade pipeline.Updated
aai_cli/commands/agent_cascade/_exec.py:run_agent_cascade()callsload_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--filesand not reflected in--show-codeoutput.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
CLAUDE.mdsymlinked toAGENTS.md) is deduplicated on content, not filename, so it works across platforms without depending on symlink support.None, not an empty heading).[project context truncated]signals to the model when it's seeing only the head of an oversized file.--filesor any other flag.https://claude.ai/code/session_01QegBRMt1QU2LRvbEMyCdiT