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:
@@ -1,6 +1,6 @@
|
||||
//! Integration tests for project context loading and ordering.
|
||||
//!
|
||||
//! Tests that the context window has the correct structure when projects are loaded.
|
||||
//! Tests that the context window has the correct structure when project context is loaded.
|
||||
//! Also tests that project content survives compaction.
|
||||
|
||||
use g3_core::{
|
||||
@@ -11,7 +11,7 @@ use g3_config::Config;
|
||||
use g3_providers::{mock::MockProvider, ProviderRegistry, MockResponse, MessageRole};
|
||||
|
||||
/// Helper to create a test agent with mock provider
|
||||
async fn create_test_agent(readme_content: Option<String>) -> Agent<NullUiWriter> {
|
||||
async fn create_test_agent(project_context: Option<String>) -> Agent<NullUiWriter> {
|
||||
let config = Config::default();
|
||||
let provider = MockProvider::new()
|
||||
.with_response(MockResponse::text("Test response"));
|
||||
@@ -19,7 +19,7 @@ async fn create_test_agent(readme_content: Option<String>) -> Agent<NullUiWriter
|
||||
let mut registry = ProviderRegistry::new();
|
||||
registry.register(provider);
|
||||
|
||||
Agent::new_for_test_with_readme(config, NullUiWriter, registry, readme_content)
|
||||
Agent::new_for_test_with_project_context(config, NullUiWriter, registry, project_context)
|
||||
.await
|
||||
.expect("Failed to create test agent")
|
||||
}
|
||||
@@ -337,7 +337,7 @@ async fn create_agent_with_mock_and_readme(
|
||||
let mut registry = ProviderRegistry::new();
|
||||
registry.register(provider);
|
||||
|
||||
Agent::new_for_test_with_readme(config, NullUiWriter, registry, readme_content)
|
||||
Agent::new_for_test_with_project_context(config, NullUiWriter, registry, readme_content)
|
||||
.await
|
||||
.expect("Failed to create test agent")
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ fn test_reset_with_summary_and_stub_no_stub() {
|
||||
assert!(has_summary, "Should have summary");
|
||||
}
|
||||
|
||||
/// Test that README message is preserved during reset
|
||||
/// Test that project context message is preserved during reset
|
||||
#[test]
|
||||
fn test_reset_preserves_readme() {
|
||||
fn test_reset_preserves_project_context() {
|
||||
let mut context = ContextWindow::new(100000);
|
||||
|
||||
// Add system prompt
|
||||
@@ -115,10 +115,10 @@ fn test_reset_preserves_readme() {
|
||||
"You are a helpful assistant.".to_string(),
|
||||
));
|
||||
|
||||
// Add README message (second system message with specific content)
|
||||
// Add project context message (second system message with Agent Configuration)
|
||||
context.add_message(Message::new(
|
||||
MessageRole::System,
|
||||
"Project README: This is a test project.".to_string(),
|
||||
"🤖 Agent Configuration (from AGENTS.md):\nTest agent config.".to_string(),
|
||||
));
|
||||
|
||||
// Add conversation
|
||||
@@ -133,11 +133,11 @@ fn test_reset_preserves_readme() {
|
||||
Some(stub),
|
||||
);
|
||||
|
||||
// README should be preserved
|
||||
let has_readme = context.conversation_history.iter().any(|m|
|
||||
m.content.contains("Project README")
|
||||
// Project context should be preserved
|
||||
let has_project_context = context.conversation_history.iter().any(|m|
|
||||
m.content.contains("Agent Configuration")
|
||||
);
|
||||
assert!(has_readme, "README message should be preserved");
|
||||
assert!(has_project_context, "Project context message should be preserved");
|
||||
}
|
||||
|
||||
/// Test fragment chain integrity
|
||||
|
||||
@@ -15,7 +15,7 @@ use tempfile::TempDir;
|
||||
async fn create_test_agent(temp_dir: &TempDir) -> Agent<NullUiWriter> {
|
||||
std::env::set_current_dir(temp_dir.path()).unwrap();
|
||||
let config = Config::default();
|
||||
Agent::new_with_readme_and_quiet(config, NullUiWriter, None, true)
|
||||
Agent::new_with_project_context_and_quiet(config, NullUiWriter, None, true)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
@@ -24,7 +24,7 @@ async fn create_test_agent(temp_dir: &TempDir) -> Agent<NullUiWriter> {
|
||||
async fn create_agent_mode_agent(temp_dir: &TempDir, agent_name: &str) -> Agent<NullUiWriter> {
|
||||
std::env::set_current_dir(temp_dir.path()).unwrap();
|
||||
let config = Config::default();
|
||||
let mut agent = Agent::new_with_readme_and_quiet(config, NullUiWriter, None, true)
|
||||
let mut agent = Agent::new_with_project_context_and_quiet(config, NullUiWriter, None, true)
|
||||
.await
|
||||
.unwrap();
|
||||
agent.set_agent_mode(agent_name);
|
||||
|
||||
@@ -54,18 +54,18 @@ fn test_reset_with_summary_preserves_system_prompt() {
|
||||
assert!(has_user_msg, "Should have the latest user message");
|
||||
}
|
||||
|
||||
/// Test that reset_with_summary preserves README message if present
|
||||
/// Test that reset_with_summary preserves project context message if present
|
||||
#[test]
|
||||
fn test_reset_with_summary_preserves_readme() {
|
||||
fn test_reset_with_summary_preserves_project_context() {
|
||||
let mut context = ContextWindow::new(10000);
|
||||
|
||||
// Add the system prompt as the first message
|
||||
let system_prompt = "You are G3, an AI programming agent...";
|
||||
context.add_message(Message::new(MessageRole::System, system_prompt.to_string()));
|
||||
|
||||
// Add README as second system message
|
||||
let readme_content = "# Project README\n\nThis is a test project.";
|
||||
context.add_message(Message::new(MessageRole::System, readme_content.to_string()));
|
||||
// Add project context as second system message (with Agent Configuration marker)
|
||||
let project_context = "🤖 Agent Configuration (from AGENTS.md):\n\nTest agent config.";
|
||||
context.add_message(Message::new(MessageRole::System, project_context.to_string()));
|
||||
|
||||
// Add some conversation history
|
||||
context.add_message(Message::new(MessageRole::User, "Task: Write a function".to_string()));
|
||||
@@ -85,15 +85,15 @@ fn test_reset_with_summary_preserves_readme() {
|
||||
"First message should be the system prompt"
|
||||
);
|
||||
|
||||
// Verify the README was preserved as the second message
|
||||
// Verify the project context was preserved as the second message
|
||||
let second_message = &context.conversation_history[1];
|
||||
assert!(
|
||||
matches!(second_message.role, MessageRole::System),
|
||||
"Second message should be a System message"
|
||||
);
|
||||
assert!(
|
||||
second_message.content.contains("Project README"),
|
||||
"Second message should be the README"
|
||||
second_message.content.contains("Agent Configuration"),
|
||||
"Second message should be the project context"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user