Skip to content

Decode goal history once into Core's declared reply - #1177

Merged
trissim merged 1 commit into
mainfrom
fix/typed-goal-history
Oct 23, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/typed-goal-history

Conversation

@trissim

@trissim trissim commented Oct 23, 2026

Copy link
Copy Markdown

Goal history now crosses Toad as Core's GoalHistoryReply, decoded once at Agent.get_goal_history. The details screen reads RecordedGoalRevision attributes and uses their existing GoalDeclaration endpoints directly; it no longer decodes each already-decoded goal or repeats JSON field names.

Owner: agent_comms.runtime_requests.GoalHistoryReply declares history: tuple[RecordedGoalRevision, ...]. agent_comms.goal_history.RecordedGoalRevision declares kind, observed_at, before and after. Core is unchanged.

Converted sites:

  • src/toad/acp/agent.py:247-249: typed return and one FieldCodec.decode(GoalHistoryReply, result).
  • src/toad/agent_binding.py:168-169: the unbound member returns an empty GoalHistoryReply.
  • src/toad/goal_interaction.py:44-52: history action names the reply type and passes it to GoalDetails.
  • src/toad/screens/goal_details.py:34-37: requires GoalHistoryReply and keeps its typed history rows.
  • src/toad/screens/goal_details.py:68-74: typed endpoints, observed_at and kind replace string-key reads and the second decode. When after is NoGoal, its declared shows_document=False selects before; require() supplies the existing Goal type. No type switch or dict fallback.
  • tests/support/goals.py:41,51,72: scripted goal owner stores and returns GoalHistoryReply, with no list/dict conversion.
  • tests/textual/test_goal_owner_views.py:31-37: fixture builds GoalHistoryReply from RecordedGoalRevision and NoGoal/Goal values.
  • tests/native/test_native_goal_owner.py:31-39: edit/history assertions read the same typed reply and typed goal endpoints.

AST inventory found three get_goal_history implementations and two call sites; all are migrated. The only GoalDetails constructor call passes the typed reply. No history-entry subscripts, get defaults, TypedDict mirror, to_dict adapter or per-entry decode remain in the screen.

Kept test_goal_history_lists_earlier_revisions, which checks the displayed historical objective, baseline and observed text and preserves the draft; its assertion function is unchanged by AST comparison and its fixture now uses the records. Also kept the native edit test's checks that accepted edits enter history and a stale rejected overwrite does not. Neither is a dict-shape-only test, so none was deleted.

Seven changed files parse; four changed production modules import with python -I and the Toad/Core source paths supplied explicitly. git diff --check passes. No tests run.

Assumed: a history entry displayed for a selected goal has a goal at one endpoint, as the old screen also required; an unbound agent's empty history remains empty. Base: Toad origin/main d3642d2.

@trissim
trissim marked this pull request as ready for review October 23, 2026 22:15
Copilot AI balanced review requested due to automatic review settings October 23, 2026 22:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit fb9906f into main Oct 23, 2026
2 of 3 checks passed
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.

2 participants