refactor(agent): extract turn assembly helpers - #17987
Open
Aliciawque wants to merge 1 commit into
Open
Conversation
Aliciawque
marked this pull request as ready for review
April 30, 2026 15:47
Contributor
|
Thanks for the focused, behavior-preserving extraction. Problems
Suggested changes
Automated hermes-sweeper review. |
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.
What does this PR do?
Extracts the API-call-time turn assembly helpers from
run_agent.pyintoagent/turn_assembly.py.This is a narrower follow-up to #6441. The original PR also included a BOOT.md gateway fix, but that motivation is now obsolete after #17093 removed the built-in BOOT.md hook. This PR keeps only the refactor portion that still has value: composing ephemeral user-context blocks, effective system prompts, and prefill message insertion without changing persisted conversation state.
Related Issue
Follow-up to #6441.
Related to #17093.
Type of Change
Changes Made
agent/turn_assembly.py- adds helpers for user context blocks, effective system prompt composition, and prefill insertion.run_agent.py- uses those helpers in the max-iteration summary path and the main conversation loop.tests/agent/test_turn_assembly.py- adds focused coverage for memory/plugin context assembly, non-string user content, system prompt composition, and prefill ordering.How to Test
Run the focused CI-parity wrapper tests:
scripts/run_tests.sh tests/agent/test_turn_assembly.py tests/run_agent/test_run_agent.py::TestRunConversation tests/run_agent/test_413_compression.py::TestHTTP413Compression::test_413_triggers_compression -qConfirm the result:
38 passedSyntax check:
python3 -m py_compile agent/turn_assembly.py run_agent.pyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (not run; focusedscripts/run_tests.shcoverage above passed)Documentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
Focused validation: