feat(core): agent orchestration & context compression optimization#384
Merged
bobleer merged 1 commit intoGCWing:mainfrom Apr 11, 2026
Merged
Conversation
Multi-layered improvements to agent stability and efficiency, referencing Claude Code's architecture patterns: Tool execution: - round_executor: convert execute_tools `?` to `match`, generate per-tool error results on pipeline failure instead of aborting the round - tool_pipeline: fallback to task_id when get_task returns None, ensuring tool_call/tool_result count always matches - tool_pipeline: partitioned mixed scheduling — consecutive concurrency-safe tools run in parallel batches, non-safe tools run serially, preserving write-after-read ordering Context compression: - Add Microcompact layer (L0): proactively clear old compactable tool results (Read/Bash/Grep/Glob/etc.) before full compression, freeing significant tokens while preserving tool call structure - Add emergency truncation (L2): drop oldest API rounds from context head when tokens still exceed context_window after all compression layers - Add compression circuit breaker: skip full compression after 3 consecutive failures (microcompact + emergency truncation always run) - Unify context_window source: use min(model_capability, session_config) in both execution_engine and coordinator manual compaction Resource cleanup: - Session eviction cleanup: delete SessionContextStore data when idle sessions are evicted from memory
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.
Summary
Multi-layered improvements to agent stability and efficiency, referencing Claude Code's architecture patterns for context compression and tool orchestration.
Tool Execution Fault Tolerance & Mixed Scheduling
execute_tools?tomatchinround_executor— on pipeline-level failure, generateis_error: trueerror results for every tool_call instead of aborting the entire roundget_taskreturnsNoneintool_pipeline, use task_id as fallback to generate error results, ensuring tool_call/tool_result count always matchesMulti-layered Context Compression
min(model_capability, session_config)Resource Cleanup
SessionContextStorein-memory data when idle sessions are evicted, preventing memory leaksChanges
round_executor.rs?→matchfault tolerancetool_pipeline.rsmicrocompact.rsexecution_engine.rscoordinator.rssession_manager.rsmessage.rsestimate_tokenspubcompression/mod.rsTest plan
cargo check— zero errors, zero warningscargo test -p bitfun-core— all 202 tests pass (including 4 new microcompact tests)