Skip to content

fix(engine): wire compaction_callback and plan_execute_config through auto-selection#601

Merged
Aureliolo merged 4 commits intomainfrom
fix/engine-auto-selection-wiring
Mar 19, 2026
Merged

fix(engine): wire compaction_callback and plan_execute_config through auto-selection#601
Aureliolo merged 4 commits intomainfrom
fix/engine-auto-selection-wiring

Conversation

@Aureliolo
Copy link
Copy Markdown
Owner

@Aureliolo Aureliolo commented Mar 19, 2026

Summary

  • Wire compaction_callback through AgentEngine._resolve_loop() and _make_default_loop() so auto-selected and default loops receive context compaction
  • Wire plan_execute_config through AgentEngine._resolve_loop() so auto-selected PlanExecuteLoop instances receive custom config
  • Add both as AgentEngine.__init__ parameters with proper type imports and docstrings
  • Remove stale docstring caveat that warned about missing config in auto-selection path
  • Add has_compaction_callback, has_plan_execute_config, has_hybrid_loop_config to EXECUTION_ENGINE_CREATED debug log
  • Add 10 unit tests covering wiring for all loop types, default path, None defaults, and hybrid_loop_config consistency

Closes #577
Closes #578

Test plan

  • All 9657 tests pass (pytest tests/ -n auto --cov=synthorg --cov-fail-under=80)
  • Coverage: 93.87% (above 80% threshold)
  • mypy strict: clean
  • ruff lint + format: clean
  • Pre-push hooks: all pass (mypy, pytest, ruff, gitleaks)
  • New tests verify compaction_callback wired to ReactLoop, PlanExecuteLoop, HybridLoop via auto-selection
  • New tests verify plan_execute_config wired to PlanExecuteLoop via auto-selection
  • New tests verify default (non-auto) path, None defaults, hybrid_loop_config consistency

Review coverage

Pre-reviewed by 12 agents: docs-consistency, code-reviewer, python-reviewer, pr-test-analyzer, conventions-enforcer, logging-audit, resilience-audit, test-quality-reviewer, async-concurrency-reviewer, issue-resolution-verifier, comment-analyzer, security-reviewer. 7 findings addressed, 1 deferred (pre-existing 800-line file limit on agent_engine.py).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Engine accepts optional compaction callback and plan execution configuration; auto-selected execution loops now forward these settings.
    • Resume/checkpoint path now supports injecting checkpoint callbacks into hybrid loops.
  • Documentation

    • Updated orchestration docs and README to list Hybrid loop and document forwarding of compaction/plan-execute/hybrid configs.
  • Tests

    • Added unit tests to verify wiring of compaction callback and plan-execute config across loop types.

Aureliolo and others added 2 commits March 19, 2026 16:23
… auto-selection

AgentEngine._resolve_loop() was calling build_execution_loop() without
passing compaction_callback or plan_execute_config. Loops created via
the auto-selection path never got compaction or custom plan-execute
config, even though the factory already supported them.

- Add compaction_callback and plan_execute_config params to AgentEngine
- Pass both through _resolve_loop() to build_execution_loop()
- Wire compaction_callback in _make_default_loop() for consistency
- Remove stale docstring caveat about missing config in auto-selection
- Add 7 unit tests covering wiring for all loop types

Closes #577
Closes #578

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move inline MagicMock import to module level in test_loop_selector.py
- Use MagicMock instead of AsyncMock in sync test
- Add None-default-path test for compaction_callback
- Add hybrid_loop_config wiring test at AgentEngine level
- Add task_id param to _make_task_with_complexity for ID consistency
- Add has_compaction_callback/has_plan_execute_config/has_hybrid_loop_config
  to EXECUTION_ENGINE_CREATED debug log

Pre-reviewed by 12 agents, 7 findings addressed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: f0b2b12a-87da-4107-9f3c-038148853b2f

📥 Commits

Reviewing files that changed from the base of the PR and between c1b3541 and a821679.

📒 Files selected for processing (6)
  • README.md
  • docs/design/engine.md
  • src/synthorg/engine/agent_engine.py
  • src/synthorg/engine/checkpoint/resume.py
  • tests/unit/engine/test_agent_engine_auto_loop.py
  • tests/unit/engine/test_loop_selector.py

Walkthrough

AgentEngine.__init__ now accepts two new optional parameters: compaction_callback and plan_execute_config. These are forwarded into build_execution_loop() during auto-selection of execution loops so dynamically chosen loops receive the compaction callback and plan-execute configuration. _resolve_loop documentation was updated to remove the prior note about omitting compaction and plan-execute config. Tests and docs were added/updated to verify that compaction_callback and plan_execute_config are propagated for ReactLoop, PlanExecuteLoop, and HybridLoop.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: wiring compaction_callback and plan_execute_config through the auto-selection path in AgentEngine, which is the primary focus of all code changes.
Linked Issues check ✅ Passed The pull request fully addresses both linked issues (#577 and #578) by adding compaction_callback and plan_execute_config as AgentEngine.init parameters and wiring them through _resolve_loop() and _make_default_loop() for auto-selected loops.
Out of Scope Changes check ✅ Passed All changes are directly related to wiring compaction_callback and plan_execute_config through auto-selection. Additional improvements (HybridLoop checkpoint support, test helpers, documentation) are closely aligned with the core objectives and necessary for complete implementation.
Docstring Coverage ✅ Passed Docstring coverage is 75.86% which is sufficient. The required threshold is 40.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the configurability of the AgentEngine by enabling the proper propagation of compaction_callback and plan_execute_config through both default and auto-selected execution loop paths. Previously, these critical configurations were not consistently applied, leading to potential limitations in dynamic agent behavior. The changes ensure that all execution loops, regardless of how they are instantiated, can leverage these configurations, thereby improving the engine's flexibility and addressing existing configuration gaps.

Highlights

  • Enhanced AgentEngine Configuration: Introduced compaction_callback and plan_execute_config as new parameters to the AgentEngine.__init__ method, allowing for more flexible configuration of agent behavior.
  • Configuration Wiring for Execution Loops: Ensured that compaction_callback is correctly passed to both default and auto-selected ReactLoop, PlanExecuteLoop, and HybridLoop instances, and that plan_execute_config is passed to auto-selected PlanExecuteLoop instances.
  • Improved Debug Logging: Updated the EXECUTION_ENGINE_CREATED debug log to include flags indicating the presence of compaction_callback, plan_execute_config, and hybrid_loop_config.
  • Docstring Refinement: Removed an outdated docstring caveat that incorrectly warned about missing configuration in auto-selection paths.
  • Comprehensive Unit Testing: Added 10 new unit tests to thoroughly verify the correct wiring of these configurations across all relevant loop types and auto-selection scenarios, ensuring robustness and reliability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Aureliolo Aureliolo temporarily deployed to cloudflare-preview March 19, 2026 15:54 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully wires compaction_callback and plan_execute_config through the AgentEngine's auto-selection and default loop paths. The changes include necessary imports, updates to __init__ parameters and assignments, and modifications to the _make_default_loop and _resolve_loop methods to pass these configurations. The removal of the stale docstring caveat is a good cleanup. Comprehensive unit tests have been added to cover the new wiring for all relevant loop types, default paths, and None defaults, ensuring the functionality works as expected. No critical, high, or medium severity issues were identified in the provided changes.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/engine/test_agent_engine_auto_loop.py`:
- Around line 515-545: Move the local import of HybridLoopConfig out of the test
body to the module-level imports for consistency: remove the inline "from
synthorg.engine.hybrid_models import HybridLoopConfig" inside
test_hybrid_loop_config_wired_via_auto_selection and add the same import
alongside the other top-level imports (where PlanExecuteConfig is imported);
keep the test name test_hybrid_loop_config_wired_via_auto_selection, the
HybridLoopConfig symbol, and the rest of the test logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: e7a7e96d-6c2b-4b91-be67-96ead75f08ee

📥 Commits

Reviewing files that changed from the base of the PR and between c8bf862 and c1b3541.

📒 Files selected for processing (3)
  • src/synthorg/engine/agent_engine.py
  • tests/unit/engine/test_agent_engine_auto_loop.py
  • tests/unit/engine/test_loop_selector.py

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.45%. Comparing base (e2d86a3) to head (a821679).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/synthorg/engine/checkpoint/resume.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #601      +/-   ##
==========================================
- Coverage   92.46%   92.45%   -0.01%     
==========================================
  Files         551      551              
  Lines       27681    27686       +5     
  Branches     2678     2679       +1     
==========================================
+ Hits        25595    25598       +3     
- Misses       1634     1635       +1     
- Partials      452      453       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Aureliolo and others added 2 commits March 19, 2026 17:19
…bit, and Gemini

- Expand warning when execution_loop provided externally to include
  compaction_callback alongside approval_gate and stagnation_detector
- Add 5 missing __init__ params to AgentEngine class docstring
  (parked_context_repo, checkpoint_repo, heartbeat_repo,
  checkpoint_config, stagnation_detector)
- Add externally-provided-loop caveat to compaction_callback docstring
- Add HybridLoop branch to make_loop_with_callback in checkpoint/resume
  so checkpoint callback is no longer silently dropped for hybrid loops
- Update design spec step 8 to document callback/config wiring through
  auto-selection, mention plan_execute_config/hybrid_loop_config/
  compaction_callback as AgentEngine parameters
- Add Hybrid to README execution loops list
- Move HybridLoopConfig import to module level in test file (CodeRabbit)
- Remove empty lines left after inline import removal in test_loop_selector
- Add docstrings to 2 new build_execution_loop test methods
- Add agent_id/task_id assertions to resume path test
- Add test for plan_execute_config=None default fallback via auto-selection
- Add test for both compaction_callback and plan_execute_config wired
  simultaneously
- Extract _make_plan_exec_responses/_make_hybrid_responses test helpers
  to reduce response-building duplication across budget-aware tests
- Create GitHub issues #614 and #615 for deferred security findings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mypy strict requires generic list type parameters. Import
CompletionResponse and annotate _make_plan_exec_responses and
_make_hybrid_responses return types as list[CompletionResponse].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Aureliolo Aureliolo merged commit 795327f into main Mar 19, 2026
31 of 33 checks passed
@Aureliolo Aureliolo deleted the fix/engine-auto-selection-wiring branch March 19, 2026 16:34
@Aureliolo Aureliolo temporarily deployed to cloudflare-preview March 19, 2026 16:34 — with GitHub Actions Inactive
Aureliolo added a commit that referenced this pull request Mar 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.8](v0.3.7...v0.3.8)
(2026-03-19)


### Features

* dynamic settings UI with auto-discovery and basic/advanced toggle
([#600](#600))
([11b32b7](11b32b7))


### Bug Fixes

* **ci:** remove dst: . from GoReleaser archive config
([#598](#598))
([c8bf862](c8bf862))
* **engine:** wire compaction_callback and plan_execute_config through
auto-selection
([#601](#601))
([795327f](795327f))
* harden setup wizard completion and status checks
([#616](#616))
([d99d7b7](d99d7b7))


### Maintenance

* add /codebase-audit skill for deep parallel codebase auditing
([#613](#613))
([db02320](db02320))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant