refactor(core): collapse ConversationState into typed Continuation#210
Merged
Conversation
Continuation previously round-tripped through the legacy `_conversation_state` dict on every turn (build_conversation_state -> ConversationState -> Continuation, and back), carrying a second, parallel versioning scheme. This is the "compatibility drag inside the core" the v2 sketch forbids, and it sat on the agent loop's hot path. - Replace the dict shape + adapters bridge with a single typed build_continuation() that assembles the next Continuation from typed Message/Continuation objects directly. - Delete src/pollux/continuation.py and src/pollux/interaction/adapters.py (~260 lines); move history_text_from_parts into parts.py. - Preserve prior tool-call `index` across turns (the dict round-trip dropped it). Also: - completion_status: unrecognized finish reasons now read "clean" instead of "cutoff" (drop the dead _CUTOFF_FINISH branch + unused _CLEAN_FINISH set), so a harness won't compact/retry on an unknown-but-successful stop. - Add a regression test proving local-server reasoning is display-only and never re-enters the continuation or the replayed payload. - Remove stale Slice-N / v1 build-process references from docstrings.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
Continuation state previously round-tripped through the legacy
_conversation_statedict on every turn (build_conversation_state→ConversationState→Continuation, and back via an adapters bridge), carrying a second, parallel versioning scheme. That is the "compatibility drag inside the core" the v2 interaction sketch forbids, and it sat on the agent loop's hot path. This collapses it into a single typed builder, and folds in two small, related fixes.build_continuation()that assembles the nextContinuationfrom typedMessage/Continuationobjects directly.src/pollux/continuation.pyandsrc/pollux/interaction/adapters.py(~260 lines); movehistory_text_from_partsintoparts.py. Net −164 lines, one conceptual layer removed. The provider boundary already consumed typed primitives, so provider replay is untouched.completion_status: unrecognized finish reasons now read"clean"instead of"cutoff"(removes the dead_CUTOFF_FINISHbranch and unused_CLEAN_FINISHset), so a harness won't compact/retry on an unknown-but-successful stop.Slice N/ v1 build-process references from docstrings (no longer accurate post-cutover).No public API change;
Continuation/Output/Inputshapes are unchanged. A side benefit: prior tool-callindexis now preserved across turns (the dict round-trip silently dropped it).Related issue
None
Test plan
just check- green (415 passed, 19 deselected; ruff format/lint + mypy clean).tests/interaction/test_output.pyfor the newcompletion_statusdefault (weird_unknown→clean).tests/providers/test_local_contract.py::test_local_reasoning_is_display_only_and_not_replayed, proving local-serverreasoning_contentsurfaces onOutput.reasoningbut never enters the continuation's replay messages/provider_stateor the next replayed payload (the sketch's Local Providers rule).Notes
pollux.continuationandpollux.interaction.adapterswere never part of the public surface (not inpollux.__all__), and no code outsidesrc/referenced them.