The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(claude-agent-sdk): send every system message, not just the first\n\nThe CLI takes one `--system-prompt`, and the adapter picked it with a\n`find_map` over the messages — so any system message after the persona was\ndropped before the request left the process.\n\nWhat that drops is not incidental. The artifact contents list and the turn-cap\nwrap-up are appended as system messages *precisely because* a system message is\nthe one thing compression and the trim will not remove. Extracting only the\nfirst put them back to being removable, on this provider alone, with nothing\nlogged. A capped or compacted turn on `ClaudeAgentSdkProvider` therefore lost\nevery artifact pointer this PR adds.\n\n`coalesce_system_prompt` joins them in order, so the persona still leads.\n\nReported by chatgpt-codex-connector on #6068; it had gone unaddressed since the\nfirst review round.\n\n
sanil-2393d35e7d21d4
diff --git a/src/openhuman/inference/provider/claude_agent_sdk/subprocess.rs b/src/openhuman/inference/provider/claude_agent_sdk/subprocess.rsindex 9a1d69fcd2..d32e62255b 100644--- a/src/openhuman/inference/provider/claude_agent_sdk/subprocess.rs+++ b/src/openhuman/inference/provider/claude_agent_sdk/subprocess.rs@@ -261,10 +261,7 @@ impl ChatModel<()> for ClaudeAgentSdkProvider {) -> tinyinference::Result<ModelResponse> {let messages = coalesce_prompt_tool_results(&request.messages);let messages = with_prompt_tool_instructions(&messages, &request.tools);- let system = messages.iter().find_map(|message| match message {- Message::System(_) => Some(message.text()),- _ => None,- });+ let system = coalesce_system_prompt(&messages);let last_user = messages.iter().rev()@@ -291,6 +288,24 @@ impl ChatModel<()> for ClaudeAgentSdkProvider {}}+/// Join every system message into the one system prompt the CLI accepts.+///+/// The CLI takes a single `--system-prompt`, and this used to `find_map` the+/// first system message and drop the rest (codex on #6068). What gets dropped is+/// not incidental: the artifact contents list and the turn-cap wrap-up are both+/// appended as system messages *precisely because* a system message is the one+/// thing compression and the trim will not remove. Taking only the first put+/// them back to being removable — on this provider alone, and silently.+fn coalesce_system_prompt(messages: &[Message]) -> Option<String> {+ let parts: Vec<String> = messages+ .iter()+ .filter(|message| matches!(message, Message::System(_)))+ .map(|message| message.text())+ .filter(|text| !text.trim().is_empty())+ .collect();+ (!parts.is_empty()).then(|| parts.join("\n\n"))+}+#[cfg(test)]#[path = "subprocess_tests.rs"]mod tests;diff --git a/src/openhuman/inference/provider/claude_agent_sdk/subprocess_tests.rs b/src/openhuman/inference/provider/claude_agent_sdk/subprocess_tests.rsindex 87ee1b134c..ec920180aa 100644--- a/src/openhuman/inference/provider/claude_agent_sdk/subprocess_tests.rs+++ b/src/openhuman/inference/provider/claude_agent_sdk/subprocess_tests.rs@@ -212,3 +212,40 @@ printf '%s\n' '{"type":"result","result":"Calling.<tool_call>{\"name\":\"lookup\Some("claude-agent-sdk"));}++/// The CLI takes one `--system-prompt`, so every system message has to be+/// folded into it. Taking only the first dropped the artifact contents list and+/// the turn-cap wrap-up, which are appended as system messages exactly so the+/// context ladder cannot remove them (codex on #6068).+#[test]+fn every_system_message_reaches_the_cli_prompt() {+ let messages = vec![+ Message::system("you are a helpful agent"),+ Message::user("fetch the issues"),+ Message::system("## Stored results from this turn\n\n- `file_read` → `a.json`"),+ ];++ let system = coalesce_system_prompt(&messages).expect("a system prompt");++ assert!(+ system.contains("you are a helpful agent"),+ "the persona must survive: {system}"+ );+ assert!(+ system.contains("Stored results from this turn"),+ "a later system message must not be dropped: {system}"+ );+ assert!(+ system.find("you are a helpful agent") < system.find("Stored results"),+ "order must be preserved so the persona still leads: {system}"+ );+}++#[test]+fn a_conversation_with_no_system_message_yields_none() {+ let messages = vec![Message::user("hello")];+ assert!(coalesce_system_prompt(&messages).is_none());+ // Blank system messages are not a prompt either.+ let blank = vec![Message::system(" ")];+ assert!(coalesce_system_prompt(&blank).is_none());+}