feat(agent): add turn lineage support for derived turns#1556
Open
mt-hub8 wants to merge 5 commits into
Open
Conversation
mt-hub8
force-pushed
the
feat/turn-lineage-clean
branch
from
July 23, 2026 07:42
873f4dc to
63677ad
Compare
Introduce TurnMetadata (ParentTurnID + Relation) that flows through the
existing SendInput -> Runtime Exec -> Turn persistence pipeline, allowing
Retry to create a new Turn in the same Session with a parent_turn_id
link, without introducing Child Sessions or modifying Provider APIs.
Changes:
- Store: add parent_turn_id and relation columns to workspace_agent_turns
(nullable, CHECK constraint on relation: 'retry', 'edit')
- Migration: workspace_agent_turn_lineage_v1 ALTER TABLE + CREATE TABLE
column inclusion for drop-rebuild compatibility
- Runtime: TurnMetadata struct threaded through ExecInput -> beginTurn ->
submittedTurnActivityEvents -> event.Payload.Metadata
- Canonical/Compat: ParentTurnID + Relation added to WorkspaceAgentTurnPatch,
WorkspaceAgentTurnStateUpdate, TurnTransition, Turn
- Daemon adapter: mapTurnMetadataFromService bridges host -> runtime types
- Host API: Host.RetryTurn validates turn settled + extracts user message +
calls SendInput with TurnMetadata{ParentTurnID, Relation: "retry"}
- Tests: Store lineage persistence (3 tests) + Host RetryTurn validation (6 tests)
Design principles:
- Retry/Edit creates a new Turn; historical Turns are never modified
- Runtime has zero Retry/Edit business logic (generic metadata pass-through)
- Provider is unaware of Retry/Edit (no context replay, no API changes)
- Normal SendInput without TurnMetadata is fully backward compatible
Signed-off-by: WorkBuddy <noreply@codebuddy.cn>
Signed-off-by: man tuo <2428184991@qq.com>
Introduce parent_turn_id/relation infrastructure across Host, store, and runtime so derived turns (Retry first) can record lineage without mutating the parent turn. Add Host conformance coverage for RetryTurn. Signed-off-by: man tuo <2428184991@qq.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: man tuo <2428184991@qq.com>
Signed-off-by: man tuo <2428184991@qq.com>
Signed-off-by: man tuo <2428184991@qq.com>
mt-hub8
force-pushed
the
feat/turn-lineage-clean
branch
from
July 23, 2026 09:14
63677ad to
b9a2108
Compare
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
main(5e4e011fc) after resolving conflicts with capability-refs / TuttiMode / submit provenance fields that landed on trunk.parent_turn_id/relation) across Host, store-sqlite, and runtime so derived turns (Retry first) can record lineage without mutating the parent turn.RetryTurn.Supersedes closed PR #1549 (GitHub could not reopen that PR after the rebase force-push).
Test plan
go test ./packages/agent/host/ ./packages/agent/host/conformance/ ./packages/agent/store-sqlite/ ./packages/agent/daemon/runtime/go test ./services/tuttid/service/agent/ -run 'Conformance|Retry|Lineage|Host'Made with Cursor