Skip to content

refactor(core): extract ContextManager, ToolOrchestrator, LearningEngine from Agent#900

Merged
bug-ops merged 2 commits intomainfrom
feat/830-agent-decomposition
Feb 25, 2026
Merged

refactor(core): extract ContextManager, ToolOrchestrator, LearningEngine from Agent#900
bug-ops merged 2 commits intomainfrom
feat/830-agent-decomposition

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 25, 2026

Summary

  • Extract ContextManager from Agent — owns budget/compaction config, token_counter, should_compact() (replaces ContextState)
  • Extract ToolOrchestrator — owns doom loop history, max iterations, overflow config, is_doom_loop() detection
  • Extract LearningEngine — owns learning config and reflection state, is_enabled()/check_improvement_allowed()
  • Agent delegates to these structs via thin wrappers; no behavior change

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace -- -D warnings passes (0 warnings)
  • cargo nextest run --workspace --lib --bins — 2693 passed, 9 skipped
  • Security audit: no unsafe, proper visibility, no secret leakage
  • Code review: approved, no blocking issues

Closes #836, closes #837, closes #838
Part of #830

@github-actions github-actions bot added documentation Improvements or additions to documentation rust core refactor size/L labels Feb 25, 2026
…ine from Agent

Break the Agent god object into focused subsystems with clear ownership:

- ContextManager: owns budget/compaction config, token_counter,
  should_compact() and prune logic (replaces ContextState)
- ToolOrchestrator: owns doom_loop_history, max_iterations,
  overflow_config, is_doom_loop() detection
- LearningEngine: owns learning config and reflection state,
  is_enabled()/check_improvement_allowed() methods

Agent delegates to these structs via thin wrappers. No behavior change,
all 2693 tests pass unmodified.

Closes #836, closes #837, closes #838
Part of #830
…ningEngine

docs(arch): update crates.md and overview.md for agent decomposition
docs(readme): add new agent subsystems to zeph-core README

17 new unit tests covering:
- ToolOrchestrator: doom loop detection, hash push/clear, boundary cases
- LearningEngine: reflection lifecycle, is_enabled with config variants
- ContextManager: should_compact with/without budget, threshold, empty messages
@bug-ops bug-ops force-pushed the feat/830-agent-decomposition branch from ae251e8 to 6e36618 Compare February 25, 2026 17:26
@github-actions github-actions bot added size/XL and removed size/L labels Feb 25, 2026
@bug-ops bug-ops enabled auto-merge (squash) February 25, 2026 17:28
@bug-ops bug-ops merged commit 15c66a6 into main Feb 25, 2026
28 checks passed
@bug-ops bug-ops deleted the feat/830-agent-decomposition branch February 25, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core documentation Improvements or additions to documentation refactor rust size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract LearningEngine from Agent Extract ToolOrchestrator from Agent Extract ContextBuilder from Agent into standalone struct

1 participant