Skip to content

feat(agent): add turn lineage support for derived turns#1556

Open
mt-hub8 wants to merge 5 commits into
tutti-os:mainfrom
mt-hub8:feat/turn-lineage-clean
Open

feat(agent): add turn lineage support for derived turns#1556
mt-hub8 wants to merge 5 commits into
tutti-os:mainfrom
mt-hub8:feat/turn-lineage-clean

Conversation

@mt-hub8

@mt-hub8 mt-hub8 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • Rebased onto latest main (5e4e011fc) after resolving conflicts with capability-refs / TuttiMode / submit provenance fields that landed on trunk.
  • Adds turn lineage (parent_turn_id / relation) across Host, store-sqlite, and runtime so derived turns (Retry first) can record lineage without mutating the parent turn.
  • Adds Host conformance coverage for 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'
  • CI green on this PR

Made with Cursor


Open in Devin Review

@tutti-pr-review-bot
tutti-pr-review-bot Bot requested a review from a team July 23, 2026 07:38
devin-ai-integration[bot]

This comment was marked as resolved.

@mt-hub8
mt-hub8 force-pushed the feat/turn-lineage-clean branch from 873f4dc to 63677ad Compare July 23, 2026 07:42
mt-hub8 and others added 5 commits July 23, 2026 17:06
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>
@mt-hub8
mt-hub8 force-pushed the feat/turn-lineage-clean branch from 63677ad to b9a2108 Compare July 23, 2026 09:14
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