Skip to content

refactor(core): collapse ConversationState into typed Continuation#210

Merged
seanbrar merged 1 commit into
mainfrom
refactor/collapse-conversation-state
Jun 16, 2026
Merged

refactor(core): collapse ConversationState into typed Continuation#210
seanbrar merged 1 commit into
mainfrom
refactor/collapse-conversation-state

Conversation

@seanbrar

@seanbrar seanbrar commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Continuation state previously round-tripped through the legacy _conversation_state dict on every turn (build_conversation_stateConversationStateContinuation, 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.

  • Replace the dict shape + adapters bridge with one 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. 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_FINISH branch and unused _CLEAN_FINISH set), so a harness won't compact/retry on an unknown-but-successful stop.
  • Remove stale Slice N / v1 build-process references from docstrings (no longer accurate post-cutover).

No public API change; Continuation/Output/Input shapes are unchanged. A side benefit: prior tool-call index is 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).
  • Updated tests/interaction/test_output.py for the new completion_status default (weird_unknownclean).
  • Added tests/providers/test_local_contract.py::test_local_reasoning_is_display_only_and_not_replayed, proving local-server reasoning_content surfaces on Output.reasoning but never enters the continuation's replay messages/provider_state or the next replayed payload (the sketch's Local Providers rule).
  • Continuation assembly itself is covered by the existing interaction/pipeline boundary tests, which all pass against the typed builder.

Notes

  • Breaking internal only - pollux.continuation and pollux.interaction.adapters were never part of the public surface (not in pollux.__all__), and no code outside src/ referenced them.

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

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pollux/interaction/continuation.py 91.30% 2 Missing ⚠️
src/pollux/parts.py 84.61% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@seanbrar seanbrar merged commit b38aa30 into main Jun 16, 2026
10 checks passed
@seanbrar seanbrar deleted the refactor/collapse-conversation-state branch June 16, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant