Remove automatic README loading from context window

README.md is no longer auto-loaded into the LLM context at startup.
This saves ~4,600 tokens per session while AGENTS.md and memory.md
still provide all critical information for code tasks.

Changes:
- Delete read_project_readme() function
- Remove readme_content parameter from combine_project_content()
- Rename extract_readme_heading() -> extract_project_heading()
- Rename Agent constructors: *_with_readme_* -> *_with_project_context_*
- Update context preservation to only check for Agent Configuration
- Remove has_readme field from LoadedContent
- Update all tests to use new markers and function names

The LLM can still read README.md on-demand via read_file when needed.
This commit is contained in:
Dhanji R. Prasanna
2026-01-29 11:07:41 +11:00
parent 05d253ee2a
commit 7bfb9efa19
16 changed files with 113 additions and 174 deletions

View File

@@ -283,8 +283,8 @@ Format this as a detailed but concise summary that can be used to resume the con
if let Some(system_prompt) = preserved.system_prompt {
self.add_message(system_prompt);
}
if let Some(readme) = preserved.readme {
self.add_message(readme);
if let Some(project_context) = preserved.project_context {
self.add_message(project_context);
}
// Add ACD stub if provided (before summary so LLM knows about dehydrated context)
@@ -322,10 +322,10 @@ Format this as a detailed but concise summary that can be used to resume the con
fn extract_preserved_messages(&self) -> PreservedMessages {
let system_prompt = self.conversation_history.first().cloned();
let readme = self.conversation_history.get(1).and_then(|msg| {
// Look for project context (AGENTS.md, memory, etc.) in the second message
let project_context = self.conversation_history.get(1).and_then(|msg| {
if matches!(msg.role, MessageRole::System)
&& (msg.content.contains("Project README")
|| msg.content.contains("Agent Configuration"))
&& msg.content.contains("Agent Configuration")
{
Some(msg.clone())
} else {
@@ -343,7 +343,7 @@ Format this as a detailed but concise summary that can be used to resume the con
PreservedMessages {
system_prompt,
readme,
project_context,
last_assistant_message,
}
}
@@ -740,7 +740,7 @@ Format this as a detailed but concise summary that can be used to resume the con
/// Messages preserved across compaction.
struct PreservedMessages {
system_prompt: Option<Message>,
readme: Option<Message>,
project_context: Option<Message>,
last_assistant_message: Option<Message>,
}