refactor(acp): centralize ACP session config wiring#1834
Merged
Conversation
Introduce AgentSessionConfig with from_config() constructor and Agent::apply_session_config() method that replaces ~25 individual builder calls across spawn_acp_agent, runner.rs, and daemon.rs. Any new field added to AgentConfig is now wired in one place and propagated to all channels automatically, preventing feature drift. - Add AgentSessionConfig struct with 25 config-derived fields - Add AgentSessionConfig::from_config(&Config, budget_tokens) mapping all fields - Add Agent::apply_session_config() destructuring by value for compile-time exhaustiveness - Shrink SharedAgentDeps: replace 25 scalar fields with session_config - Remove 60-line field-copy block from spawn_acp_agent - Apply centralization to runner.rs and daemon.rs - Fix daemon.rs missing orchestration_config and server_compaction wiring - Replace hardcoded 0.20 with CONTEXT_BUDGET_RESERVE_RATIO constant - Add tests: apply_session_config_wires_graph_orchestration_anomaly, apply_session_config_skips_anomaly_detector_when_disabled
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.
Closes #1812
Summary
AgentSessionConfiginzeph-corewithfrom_config(&Config, budget_tokens)— single constructor mapping all 25 config-derived fieldsAgent::apply_session_config(cfg: AgentSessionConfig)— takes ownership and destructures by value (compile-time exhaustiveness on consumption side)spawn_acp_agent,runner.rs, anddaemon.rswith a singleapply_session_config()calldaemon.rswas missingorchestration_configandserver_compactionwiring0.20with exportedCONTEXT_BUDGET_RESERVE_RATIOconstantAny new field added to
AgentConfignow requires exactly 3 edits (add field, map infrom_config, apply inapply_session_config) vs the previous 6+ manual edits across 3 files. Compile-time enforcement prevents silent omissions.Test plan
cargo nextest run --workspace --features full --lib --bins)cargo clippy --workspace --features full -- -D warningscleancargo +nightly fmt --checkcleanapply_session_config_wires_graph_orchestration_anomaly,apply_session_config_skips_anomaly_detector_when_disabledacp_auth_bearer_tokenstays inSharedAgentDeps