refactor: extract turn assembly; fix gateway BOOT.md startup guard - #6441
refactor: extract turn assembly; fix gateway BOOT.md startup guard#6441Aliciawque wants to merge 2 commits into
Conversation
|
Follow-up context for reviewers: This PR intentionally bundles two tightly related changes:
Reason for bundling: the PR is a small runtime-boundary cleanup plus a closely adjacent gateway startup guard, both validated in the same focused regression pass. Focused validation run used for this PR: Result:
|
|
Thanks for the update. Since #5239 was resolved by #17093 and the BOOT.md built-in hook has been removed, the gateway fix here is no longer applicable. I’ll close this PR rather than keep a stale/conflicting refactor open. If the turn assembly / tool runtime extraction is still useful later, I can revisit it as a smaller focused PR against current main. |
What does this PR do?
This PR extracts two explicit Phase 1 runtime seams from
run_agent.pywhile preserving existing external behavior:agent/turn_assembly.pyagent/tool_runtime.pyIt also hardens the built-in gateway
BOOT.mdstartup hook so it only runs when a gateway model can be resolved, and addsHERMES_DISABLE_BOOT_MDas an explicit disable switch.The intent is to make turn preparation and tool-result handling easier to reason about without changing approval, registry dispatch, or legacy tool-message compatibility.
Related Issue
Fixes #5239
Type of Change
Changes Made
agent/turn_assembly.pywithTurnAssembly/SideChannelContexthelpers for API-call-time prompt assemblyagent/tool_runtime.pywithToolExecutionEnvelope/ToolFailurenormalization helpersrun_agent.pytests/agent/test_turn_assembly.pytests/agent/test_run_agent_context_references.pytests/agent/test_tool_runtime.pytests/run_agent/test_run_agent.pydocs/architecture/2026-04-09-hermes-runtime-organs-rfc.mddocs/architecture/2026-04-09-phase1-runtime-organs-implementation-plan.mdgateway/builtin_hooks/boot_md.pynow resolves the configured gateway model before runningBOOT.mdgateway/hooks.pynow supports disabling the built-in boot hook viaHERMES_DISABLE_BOOT_MDHow to Test
pytest -q tests/agent/test_turn_assembly.py tests/agent/test_run_agent_context_references.py tests/agent/test_tool_runtime.py tests/run_agent/test_run_agent.py tests/agent/test_context_references.py tests/run_agent/test_agent_loop_tool_calling.py tests/run_agent/test_dict_tool_call_args.py tests/run_agent/test_tool_arg_coercion.py tests/run_agent/test_agent_loop.py323 passed1 skipped0 failedBOOT.mdruns normallyHERMES_DISABLE_BOOT_MD=1and confirm the built-in startup hook is not registeredChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Focused validation result:
323 passed1 skipped0 failed