offer_retry: the coordinator puts a failed merge in front of the person
Stuck tasks (c). The coordinator cannot merge. For a merge that failed and ended (the task back at Ready to merge), offer_retry raises the merge card in the person's conversation, asking whether to try it again (Merge / Not now). Nothing is dispatched by the tool: the card's Merge is answerMerge, the person's own path (personMerge, the gate deciding for them at the tap, DecidedBy person), so rule 2 holds. It is offered only when that tap could merge now (mergeOffered and the gate for the person, neither recorded), once while a card is open, and is held to one offer per task in a turn by the ledger (retry_offer). It is a write tool, fenced when a hand-off is cancelled, never in a move-in turn. Protocol 30: Encode refuses the call below it, and the runner answers it locally (stuck_unsupported) on an older link, in the bridge and when a queued call meets an older connection, so it never replays later. The opening's merge rule names the one exception; houseRule moves to 2026-11-25.1 so sessions start under it. Copy, pending Paul's review (COPY REVIEW PENDING, inventory rows added): chat.merge.retry_offer, chat.activity.offer_retry. Tests: wire TestProtocol30StuckTools; runner/thin TestStuckToolsRefusedOnAnOlderLink, TestStuckToolUnencodableCallIsRetired; thintest TestContractOfferRetryMerge (no dispatch until the tap, one card, replay, the tap merges as the person), TestContractOfferRetry- OnlyWhatTheTapCanMerge; existing TestActivityLabels, mcp and converse policy tests cover the new tool's label, schema and launch policy. Mutation checks (each observed failing, then restored): - tool calls personMerge itself: TestContractOfferRetryMerge (dispatch) - open-card check removed: same test (second offer) - failed-merge check removed: same test (offered while merging) - merge_asked not set: same test (the tap is refused as stale) - Encode passes the call below 30: TestProtocol30StuckTools - bridge / link not refusing on an old link: the two runner tests - mergeOffered and the gate check are redundant guards: each alone survives; removed together, TestContractOfferRetryOnlyWhatTheTapCanMerge fails (offered with the branch away)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 files changed,
+390
−21
docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+2 −0internal/equipo/chat/handoff.go+1 −1internal/equipo/chat/stuck.go+95 −0internal/equipo/chat/tasks.go+2 −0internal/equipo/chat/tools.go+5 −1internal/equipo/copy.go+2 −0internal/runner/provider/actions.go+1 −1internal/runner/provider/claude/launcher.go+1 −1internal/runner/thin/bridge.go+3 −0internal/runner/thin/claude.go+2 −2internal/runner/thin/link.go+5 −1internal/runner/thin/mcp.go+1 −0internal/runner/thin/stuck.go+20 −0internal/runner/thin/stuck_test.go+89 −0internal/thintest/stuck_contract_test.go+94 −0internal/wire/frames.go+4 −2internal/wire/runners.go+8 −3internal/wire/stuck.go+26 −9internal/wire/stuck_test.go+29 −0
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 2d0d402b..80c2f1d7 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6904,6 +6904,8 @@ records remain unchanged. |
| | `api.already_running` | A request to run this work is already in progress. | A second Run now for the same hold (paused work review S2) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `api.offer_changed` | The option to run this work has changed. Check the current option, then try again. | A Run now tap whose offer changed since the page was drawn (paused work re-review R1) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| | `work.pause.run_now_may_bill` | This may use a plan that bills per use. | Under plain Run it now anyway, for an older runner, when a pay-per-use connection could take it (re-review R1) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) | |
| +| `chat.merge.retry_offer` | Merging %s didn’t go through. Try the merge again? | Copy specialist | COPY REVIEW PENDING | |
| +| `chat.activity.offer_retry` | Offering to try the merge again… | Copy specialist | COPY REVIEW PENDING | |
| ## Task 21 |
diff --git a/internal/equipo/chat/handoff.go b/internal/equipo/chat/handoff.go| index 92b147c2..6af94afd 100644 |
| --- a/internal/equipo/chat/handoff.go |
| +++ b/internal/equipo/chat/handoff.go |
| @@ -482,7 +482,7 @@ func (t *txn) handoffOf(turnID, taskID string) (handoffRecord, bool, error) { |
| // workTools create, start or change work: once the person cancels a |
| // request (stopping or cancelled), its turns may run none of them. |
| -var workTools = []string{wire.ToolRecordTask, wire.ToolStartTask, wire.ToolAddFinding, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolProposeSpecialist, wire.ToolResearch} |
| +var workTools = []string{wire.ToolRecordTask, wire.ToolStartTask, wire.ToolAddFinding, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolProposeSpecialist, wire.ToolResearch, wire.ToolOfferRetry} |
| // handoffFenced: the turn belongs to a request the person cancelled and |
| // the tool would create or start work. Checked in the tool's own |
diff --git a/internal/equipo/chat/stuck.go b/internal/equipo/chat/stuck.go| new file mode 100644 |
| index 00000000..178093a7 |
| --- /dev/null |
| +++ b/internal/equipo/chat/stuck.go |
| @@ -0,0 +1,95 @@ |
| +package chat |
| + |
| +import ( |
| + "encoding/json" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/mergegate" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Stuck tasks (coordinator powers, Paul 2026-11-25): what the coordinator |
| +// may do for a task that stopped. It never merges and never publishes: a |
| +// failed merge it can only put in front of the person (offer_retry), whose |
| +// tap merges through the person's own path. |
| + |
| +// What the model reads back; people never see these. |
| +const ( |
| + toolRetryOffered = "Offered: a card in the person's conversation asks whether to try the merge again. Only their tap merges, through Equipo's merge rules; you cannot. Tell them in one line, and never say it is merged." |
| + toolNoFailedMerge = "Nothing to offer: this task has no merge that failed and ended. read_task shows where it stands." |
| + toolAlreadyOffered = "The person already has a card to try the merge again. Wait for their tap; do not ask again." |
| + toolRetryNotMergeable = "Not offered: the person's tap could not merge this task now (the branch moved, it is not approved, or Equipo's merge rules refuse it). Tell them what read_task shows." |
| +) |
| + |
| +// offerRetry is the coordinator's offer_retry: for a merge that failed and |
| +// ended, the merge card in the person's conversation asking whether to try |
| +// it again. Nothing is dispatched here. The card's Merge is answerMerge, |
| +// the person's own path (personMerge, the gate deciding for them then); it |
| +// is offered only when that tap could merge now, and once while it is open. |
| +func (t *txn) offerRetry(r turnRecord, args json.RawMessage) (wire.ToolResult, error) { |
| + var in struct { |
| + Task string `json:"task"` |
| + } |
| + if wire.Strict(args, &in) != nil { |
| + return refused("invalid", toolBadInput), nil |
| + } |
| + k, res, err := t.ownTask(r.Person, in.Task) |
| + if res != nil || err != nil { |
| + return deref(res), err |
| + } |
| + if t.isOwner(r.Person) != nil { |
| + return refused("not_owner", toolNotOwner), nil |
| + } |
| + steps, err := t.steps(k.ID) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + p := progressFor(k, steps) |
| + if p.merge == nil || p.merge.State != wire.StepFailed || !p.merge.Terminated || p.eng == nil { |
| + return refused("no_failed_merge", toolNoFailedMerge), nil |
| + } |
| + var open int64 |
| + if err := t.db.Model(&cardRecord{}).Where("task_id = ? AND kind = ? AND state = ?", k.ID, wire.CardMerge, wire.CardOpen).Count(&open).Error; err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + if open > 0 { |
| + return refused("already_offered", toolAlreadyOffered), nil |
| + } |
| + if ok, err := t.mergeOffered(k, p); err != nil || !ok { |
| + return refused("not_mergeable", toolRetryNotMergeable), err |
| + } |
| + // What the gate would say to the person's tap now; only a decision, |
| + // never recorded or acted on here. |
| + online, protocol, err := t.primaryState(p.eng.Person) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + if !online { |
| + protocol = 0 |
| + } |
| + gate, _, err := t.mergeInputs(k, p, t.personDecides(k, k.Creator), protocol) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + if mergegate.Decide(gate).Class != mergegate.ClassAct { |
| + return refused("not_mergeable", toolRetryNotMergeable), nil |
| + } |
| + now := t.now() |
| + opts, _ := json.Marshal([]string{wire.ChoiceMerge, wire.ChoiceNotNow}) |
| + c := cardRecord{ID: newID("c_"), Person: k.Creator, Kind: wire.CardMerge, State: wire.CardOpen, TurnID: r.ID, ProjectID: k.ProjectID, TaskID: k.ID, Name: k.Title, Question: t.words("chat.merge.retry_offer", k.Title), Options: string(opts), Revision: 1, CreatedAt: now, UpdatedAt: now, Lane: r.Lane} |
| + if err := t.db.Create(&c).Error; err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + // The card asks about this candidate: answerMerge acts only on it. |
| + if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("merge_asked", p.candidate).Error; err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + if t.s.authority.Audit != nil { |
| + if err := t.s.authority.Audit(t.db, "coordinator:"+r.Person, "task.merge_retry_offered", k.ID+"/"+p.merge.ID); err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + } |
| + if err := t.cardEvent(c); err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + return wire.ToolResult{Code: "offered", Text: toolRetryOffered}, nil |
| +} |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index a9bd3b10..fdb8b935 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -2185,6 +2185,8 @@ func (t *txn) runTaskTool(r turnRecord, v *wire.ToolCall) (wire.ToolResult, erro |
| return t.holdMerge(r, v.Args) |
| case wire.ToolSetMergePolicy: |
| return t.setMergePolicy(r, v.Args) |
| + case wire.ToolOfferRetry: |
| + return t.offerRetry(r, v.Args) |
| case wire.ToolAddFinding: |
| return t.addFinding(r, v.Args) |
| case wire.ToolStartTask: |
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go| index 1e3f6635..36213ec5 100644 |
| --- a/internal/equipo/chat/tools.go |
| +++ b/internal/equipo/chat/tools.go |
| @@ -318,6 +318,8 @@ func (t *txn) mutationOp(person string, v *wire.ToolCall) (string, error) { |
| return kind + ":" + strings.TrimSpace(a.Profile), nil |
| case "research": |
| return kind + ":" + strings.TrimSpace(a.Task), nil |
| + case "retry_offer": |
| + return kind + ":" + strings.TrimSpace(a.Task), nil |
| } |
| return "", nil |
| } |
| @@ -471,6 +473,8 @@ var madeCodes = map[string][]string{ |
| wire.ToolProposeSpecialist: {"proposed"}, |
| // A refused request made nothing; only a recorded run is. |
| wire.ToolResearch: {"requested"}, |
| + // A refused offer made nothing; only a raised card is in the ledger. |
| + wire.ToolOfferRetry: {"offered"}, |
| } |
| func mutated(tool, code string) bool { |
| @@ -638,7 +642,7 @@ func (t *txn) runTool(l Lease, v *wire.ToolCall) (wire.ToolResult, error) { |
| return refused("invalid", toolBadInput), nil |
| } |
| return t.starProject(r, in.Project, *in.Starred) |
| - case wire.ToolRecordTask, wire.ToolAddFinding, wire.ToolStartTask, wire.ToolReadTask, wire.ToolCancelTask, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy: |
| + case wire.ToolRecordTask, wire.ToolAddFinding, wire.ToolStartTask, wire.ToolReadTask, wire.ToolCancelTask, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolOfferRetry: |
| return t.taskTool(r, v) |
| case wire.ToolProposeSpecialist: |
| return t.toolProposeSpecialist(l, r, v) |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 824e399e..4005fb03 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -1423,6 +1423,7 @@ var pageCopy = map[string]string{ |
| "chat.activity.add_report": "Adding to the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "chat.activity.hold_merge": "Holding the merge…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "chat.activity.set_merge_policy": "Setting this project's merge rules…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| + "chat.activity.offer_retry": "Offering to try the merge again…", // COPY REVIEW PENDING |
| // Thinking words: the sets a person picks for the thinking line |
| // (Settings, Thinking words). One line per set and situation, phrases |
| // separated by " | ". Edit them here; ids and situations are in |
| @@ -2193,6 +2194,7 @@ var pageCopy = map[string]string{ |
| // Merge authority (spec 2026-11-11-equipo-merge-authority.md). |
| "chat.merge.stance_merge": "Merge %s? I'd merge: %s, but %s.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "chat.merge.stance_wait": "Merge %s? I'd wait: %s.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| + "chat.merge.retry_offer": "Merging %s didn’t go through. Try the merge again?", // COPY REVIEW PENDING |
| "chat.merge.why.approved": "approved by Review", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "chat.merge.why.small": "a small change, %d lines in %d files", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "chat.merge.why.small_one": "a small change, %d lines in one file", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
diff --git a/internal/runner/provider/actions.go b/internal/runner/provider/actions.go| index 1d4ec4f0..17f0bf89 100644 |
| --- a/internal/runner/provider/actions.go |
| +++ b/internal/runner/provider/actions.go |
| @@ -177,7 +177,7 @@ func ResearchReaderAction(action string) bool { return action == "implement" || |
| // ConverseTools is the thin coordinator's tool set (wire.ConverseTools |
| // plus create_project, which the runner carries out itself). |
| func ConverseTools() []string { |
| - return []string{"request_access", "status", "find", "search_code", "read_file", "add_project", "create_project", "set_project_home", "star_project", "ask_person", "write_note", "read_notes", "record_task", "add_finding", "start_task", "read_task", "cancel_task", "add_report", "hold_merge", "set_merge_policy", "propose_specialist", "research"} |
| + return []string{"request_access", "status", "find", "search_code", "read_file", "add_project", "create_project", "set_project_home", "star_project", "ask_person", "write_note", "read_notes", "record_task", "add_finding", "start_task", "read_task", "cancel_task", "add_report", "hold_merge", "set_merge_policy", "propose_specialist", "research", "offer_retry"} |
| } |
| // AssistTools is the Assistant's tool set (wire.AssistTools). |
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go| index 99bce3e7..9198b430 100644 |
| --- a/internal/runner/provider/claude/launcher.go |
| +++ b/internal/runner/provider/claude/launcher.go |
| @@ -140,7 +140,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode |
| } |
| tools := append(append([]string{}, native...), "mcp__equipo__permission") |
| for _, tool := range in.Tools { |
| - converse := in.Action == "converse" && slices.Contains([]string{"mcp__equipo__request_access", "mcp__equipo__status", "mcp__equipo__find", "mcp__equipo__search_code", "mcp__equipo__read_file", "mcp__equipo__add_project", "mcp__equipo__create_project", "mcp__equipo__set_project_home", "mcp__equipo__star_project", "mcp__equipo__write_note", "mcp__equipo__read_notes", "mcp__equipo__record_task", "mcp__equipo__add_finding", "mcp__equipo__start_task", "mcp__equipo__read_task", "mcp__equipo__cancel_task", "mcp__equipo__add_report", "mcp__equipo__hold_merge", "mcp__equipo__set_merge_policy", "mcp__equipo__propose_specialist", "mcp__equipo__research"}, tool) |
| + converse := in.Action == "converse" && slices.Contains([]string{"mcp__equipo__request_access", "mcp__equipo__status", "mcp__equipo__find", "mcp__equipo__search_code", "mcp__equipo__read_file", "mcp__equipo__add_project", "mcp__equipo__create_project", "mcp__equipo__set_project_home", "mcp__equipo__star_project", "mcp__equipo__write_note", "mcp__equipo__read_notes", "mcp__equipo__record_task", "mcp__equipo__add_finding", "mcp__equipo__start_task", "mcp__equipo__read_task", "mcp__equipo__cancel_task", "mcp__equipo__add_report", "mcp__equipo__hold_merge", "mcp__equipo__set_merge_policy", "mcp__equipo__propose_specialist", "mcp__equipo__research", "mcp__equipo__offer_retry"}, tool) |
| assist := in.Action == "assist" && slices.Contains([]string{"mcp__equipo__look", "mcp__equipo__describe", "mcp__equipo__use", "mcp__equipo__write_note", "mcp__equipo__read_notes"}, tool) |
| answer := in.Action == "answer" && slices.Contains([]string{"mcp__equipo__git_log", "mcp__equipo__git_diff", "mcp__equipo__git_show"}, tool) |
| research := provider.ResearchAction(in.Action) && slices.Contains([]string{"mcp__equipo__submit_findings", "mcp__equipo__keep_image"}, tool) |
diff --git a/internal/runner/thin/bridge.go b/internal/runner/thin/bridge.go| index 8ca8919e..995147eb 100644 |
| --- a/internal/runner/thin/bridge.go |
| +++ b/internal/runner/thin/bridge.go |
| @@ -595,6 +595,9 @@ func (b *bridge) roundTrip(ctx context.Context, call wire.ToolCall) wire.ToolRes |
| if res, no := accessRefused(call, b.spoken()); no { |
| return res |
| } |
| + if res, no := stuckRefused(call, b.spoken()); no { |
| + return res |
| + } |
| if res, refused := exploreRefused(call, b.spoken(), nil); refused { |
| // An instance below protocol 10 refuses it anyway (the kind is |
| // never dropped from an exploration); say why, here. |
diff --git a/internal/runner/thin/claude.go b/internal/runner/thin/claude.go| index 7acd47fa..1a99a147 100644 |
| --- a/internal/runner/thin/claude.go |
| +++ b/internal/runner/thin/claude.go |
| @@ -681,7 +681,7 @@ func (c *claudeCoordinator) idleExit() { |
| // houseRule versions the opening's rule. Changing the rule's text changes |
| // it, so sessions started under an older rule are not resumed. |
| -const houseRule = "2026-11-17.2" |
| +const houseRule = "2026-11-25.1" |
| // sessionAccount records the account and the lane's rule a session runs |
| // on. |
| @@ -775,7 +775,7 @@ func opening(person string, catalog []wire.RepoInfo) string { |
| b.WriteString("You are the Equipo coordinator for " + person + ". You talk with them about their software work. Answer briefly in plain words. Do not use em dashes.\n") |
| b.WriteString(accessPrompt + "Use the named project or the clear continuation. If placement is ambiguous, ask_person with structured placement choices, best guess first. Always confirm a new repository unless the person directly requested one in the main composer this turn. Hand-offs, nudges, quotes and ordinary card answers cannot grant creation. One turn permits one creation; placement-card labels name the repository and come from the server. Wait for the answer before recording or starting work. Learn from project corrections in your notebook. Call status to see reachable repositories and create_in namespaces.\n") |
| b.WriteString("For settled placement, call add_project for existing work or create_project for explicitly requested or confirmed new work. Choose the related namespace, otherwise home from status. Change home only when asked. Never fall back silently to a different project after a refusal.\n") |
| - b.WriteString("Once placement is settled for a bug or change, call record_task before investigating, with the repository it belongs to, a short title and their words as the brief. Then investigate with search_code and read_file, attach what you found with add_finding (a one-sentence headline for the person, plain words and no file paths, and the full finding with its file and line), and call start_task with a brief for Engineering. Engineering changes the code on the task's own branch and pushes it to Amadan; the change is then checked and reviewed, and Equipo's merge rules decide whether it merges on its own or asks the person with a card that gives Equipo's call. You cannot make it merge: when you have a concrete reason a change needs the person's look, call hold_merge with that reason. When the person says how a project should merge (\"always ask me about Suite\", \"main is not a release for Woodstar\"), call set_merge_policy with their words; a stricter rule applies at once and a looser one waits for their tap. Never offer to merge or open a pull request, and never ask the person to merge. Use ask_person only for a question only the person can answer. Mockups, prototypes, design options and spikes are explorations: record them with kind explore; they end at a preview and the person's choice of direction, never a merge. A website meant to go live is a change, not an exploration: ask Engineering for plain HTML and CSS files with no build step, kept in one folder that release/preview.json names. Once it is merged its person is asked whether to publish it; never say it is live before then.\n") |
| + b.WriteString("Once placement is settled for a bug or change, call record_task before investigating, with the repository it belongs to, a short title and their words as the brief. Then investigate with search_code and read_file, attach what you found with add_finding (a one-sentence headline for the person, plain words and no file paths, and the full finding with its file and line), and call start_task with a brief for Engineering. Engineering changes the code on the task's own branch and pushes it to Amadan; the change is then checked and reviewed, and Equipo's merge rules decide whether it merges on its own or asks the person with a card that gives Equipo's call. You cannot make it merge: when you have a concrete reason a change needs the person's look, call hold_merge with that reason. When the person says how a project should merge (\"always ask me about Suite\", \"main is not a release for Woodstar\"), call set_merge_policy with their words; a stricter rule applies at once and a looser one waits for their tap. Never offer to merge or open a pull request, and never ask the person to merge. The one exception: when a merge failed and the task waits at Ready to merge, offer_retry puts a card in front of the person to try it again, and only their tap merges. Use ask_person only for a question only the person can answer. Mockups, prototypes, design options and spikes are explorations: record them with kind explore; they end at a preview and the person's choice of direction, never a merge. A website meant to go live is a change, not an exploration: ask Engineering for plain HTML and CSS files with no build step, kept in one folder that release/preview.json names. Once it is merged its person is asked whether to publish it; never say it is live before then.\n") |
| b.WriteString("Never file the same problem twice. If record_task returns similar open tasks and one of them is what the person is reporting, call add_report on it with their words and tell them in one line it is already logged and where it stands, naming it as a markdown link; record a separate task only when it is clearly a different problem.\n") |
| b.WriteString("Speak at the outcome level: what you understood, what is happening, what you need from the person. For example: \"Got it, I've logged [Swipe back doesn't work](/tasks/tk...) and Engineering is on it.\" No file paths, line numbers or code mechanics in your replies; the diagnosis goes on the task with add_finding. Always name a task as a markdown link with its title and the link from record_task, start_task or read_task, never as \"the task card\".\n") |
| b.WriteString("Anything the person may need to paste (commands, prompts, config, codes) goes in a fenced code block, one block per thing to paste, with its kind after the opening fence (bash for a command, prompt for a prompt, text for plain text): the chat shows each block with a Copy button.\n") |
diff --git a/internal/runner/thin/link.go b/internal/runner/thin/link.go| index 9be851ea..7f059679 100644 |
| --- a/internal/runner/thin/link.go |
| +++ b/internal/runner/thin/link.go |
| @@ -474,7 +474,11 @@ func (l *Link) send(ctx context.Context, c *websocket.Conn, f wire.Frame) error |
| return err |
| } |
| if call, ok := body.(*wire.ToolCall); ok { |
| - if result, refused := accessRefused(*call, proto); refused { |
| + result, refused := accessRefused(*call, proto) |
| + if !refused { |
| + result, refused = stuckRefused(*call, proto) |
| + } |
| + if refused { |
| if err := l.State.Acked(ctx, f.ID); err != nil { |
| return err |
| } |
diff --git a/internal/runner/thin/mcp.go b/internal/runner/thin/mcp.go| index f0d184ae..7128526a 100644 |
| --- a/internal/runner/thin/mcp.go |
| +++ b/internal/runner/thin/mcp.go |
| @@ -171,6 +171,7 @@ var converseTools = []any{ |
| map[string]any{"name": "set_merge_policy", "description": "Record how Equipo merges a project, from what the person said (words: their sentence). mode is rules (merge on its own when every rule holds) or ask (ask before every merge); max_lines and max_files bound a merge without checks; main_ships is yes or no (does merging to main ship to users); add_sensitive adds path globs that always ask. A stricter change applies at once; a looser one waits for the person to tap Save on a card.", "inputSchema": toolSchema(map[string]any{"project": str, "words": str, "mode": str, "max_lines": map[string]any{"type": "integer"}, "max_files": map[string]any{"type": "integer"}, "main_ships": str, "add_sensitive": map[string]any{"type": "array", "items": str}}, "project", "words")}, |
| map[string]any{"name": "propose_specialist", "description": "Ask the person to add a specialist to their team, from Equipo's fixed menu. Only when the person wants something researched on the public web. The one profile is research-v1: it reads public web pages Equipo fetches for a task and reports what they say; it never reaches repositories. Pass profile research-v1, a short name (for example Research), a brief of at most 2 KB on what it should look for, capabilities [\"web.research\"] and tools [\"submit_findings\", \"keep_image\"], exactly those. Nothing is added until an owner taps Add on the card it raises; do not ask again in your reply. If they tap Not now, propose it again only when they ask.", "inputSchema": toolSchema(map[string]any{"profile": map[string]any{"type": "string", "enum": []string{"research-v1"}}, "name": str, "brief": str, "capabilities": map[string]any{"type": "array", "items": str}, "tools": map[string]any{"type": "array", "items": str}}, "profile", "name", "brief", "capabilities", "tools")}, |
| map[string]any{"name": "research", "description": "Ask Research (once it is on the team; see propose_specialist) to read public web pages for one of the person's tasks. Use it when an exploration or change names an outside site, brand, API or docs, or the person asking (their business, their own site), and the work needs what those pages say. task is the task id; question (at most 1,000 bytes) is what to look for, for example colours, logo, fonts, opening hours and services; urls are pages you propose (https or http, no query string, a path of at most 100 characters, at most 10), or []. URLs and bare domains the person typed on the task are read without asking; your urls are shown to the person in full on a card and read only if they tap Allow, so propose only pages the task needs and never put anything from a repository in them. This only requests a run: Equipo starts it only at the task's start (call it before start_task) or after a review round, before Engineering's next round, and Engineering waits until Research ends. At most one run per start or round and 3 per task, and Equipo never retries a run for you. Research's findings reach Engineering and Review; do not wait for them in your reply.", "inputSchema": toolSchema(map[string]any{"task": str, "question": str, "urls": map[string]any{"type": "array", "items": str, "maxItems": 10}}, "task", "question", "urls")}, |
| + map[string]any{"name": wire.ToolOfferRetry, "description": "When a task's merge failed and it waits at Ready to merge (read_task shows the failed merge step), put a card in front of the person asking whether to try the merge again. You cannot merge: only their tap merges, through Equipo's merge rules, and it is offered only when that tap could merge now. One card per task; do not ask again in your reply, and never say it is merged.", "inputSchema": toolSchema(map[string]any{"task": str}, "task")}, |
| } |
| // stepTools are the tools the implement profile pins for an Engineering |
diff --git a/internal/runner/thin/stuck.go b/internal/runner/thin/stuck.go| new file mode 100644 |
| index 00000000..3cd36be8 |
| --- /dev/null |
| +++ b/internal/runner/thin/stuck.go |
| @@ -0,0 +1,20 @@ |
| +package thin |
| + |
| +import ( |
| + "slices" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// toolStuckOld: the instance cannot take a stuck-task tool yet (below |
| +// wire.ProtocolStuckTasks). For the model; people never read it. |
| +const toolStuckOld = "Equipo needs an update before it can do that. Tell the person what stopped and that they can use Retry or Merge on the task themselves." |
| + |
| +// stuckRefused answers a stuck-task tool here on a link below protocol 30: |
| +// Encode refuses the call, so it is never sent to an older instance. |
| +func stuckRefused(call wire.ToolCall, protocol int) (wire.ToolResult, bool) { |
| + if !slices.Contains(wire.StuckTools, call.Name) || protocol == 0 || protocol >= wire.ProtocolStuckTasks { |
| + return wire.ToolResult{}, false |
| + } |
| + return wire.ToolResult{CallID: call.CallID, IsError: true, Code: "stuck_unsupported", Text: toolStuckOld}, true |
| +} |
diff --git a/internal/runner/thin/stuck_test.go b/internal/runner/thin/stuck_test.go| new file mode 100644 |
| index 00000000..e721d86f |
| --- /dev/null |
| +++ b/internal/runner/thin/stuck_test.go |
| @@ -0,0 +1,89 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "slices" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestStuckToolsRefusedOnAnOlderLink (stuck tasks, protocol 30): each |
| +// stuck-task tool is offered to the model, and a link below 30 answers it |
| +// here (an older instance has no words for it and Encode refuses the |
| +// call); at 30 it goes to the instance. Its description tells the model |
| +// that only the person's tap merges. |
| +func TestStuckToolsRefusedOnAnOlderLink(t *testing.T) { |
| + for _, name := range wire.StuckTools { |
| + if !slices.Contains(provider.ConverseTools(), name) { |
| + t.Fatalf("%s is not offered", name) |
| + } |
| + var offered map[string]any |
| + for _, tool := range converseTools { |
| + if m := tool.(map[string]any); m["name"] == name { |
| + offered = m |
| + } |
| + } |
| + if offered == nil { |
| + t.Fatalf("%s has no schema", name) |
| + } |
| + call := wire.ToolCall{CallID: "t/1/" + name, TurnID: "t", Attempt: 1, Name: name, Args: json.RawMessage(`{"task":"tk1"}`)} |
| + sent := 0 |
| + trip := func(context.Context, wire.ToolCall) wire.ToolResult { |
| + sent++ |
| + return wire.ToolResult{Code: "ok"} |
| + } |
| + old := &bridge{speaks: wire.ProtocolPinnedRelease, trip: trip} |
| + if res := old.roundTrip(context.Background(), call); !res.IsError || res.Code != "stuck_unsupported" || res.Text != toolStuckOld || sent != 0 { |
| + t.Fatalf("%s at 29: %+v, %d sent", name, res, sent) |
| + } |
| + current := &bridge{speaks: wire.ProtocolStuckTasks, trip: trip} |
| + if res := current.roundTrip(context.Background(), call); res.IsError || sent != 1 { |
| + t.Fatalf("%s at 30: %+v, %d sent", name, res, sent) |
| + } |
| + } |
| + for _, tool := range converseTools { |
| + if m := tool.(map[string]any); m["name"] == wire.ToolOfferRetry && !strings.Contains(m["description"].(string), "only their tap merges") { |
| + t.Fatalf("offer_retry's description: %s", m["description"]) |
| + } |
| + } |
| +} |
| + |
| +// TestStuckToolUnencodableCallIsRetired: a stuck-task call queued for a |
| +// link that turns out to speak 29 is answered at once and leaves the |
| +// outbox, so it never replays after an upgrade. |
| +func TestStuckToolUnencodableCallIsRetired(t *testing.T) { |
| + ctx := context.Background() |
| + s, err := OpenState(ctx, t.TempDir()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer s.Close() |
| + call := wire.ToolCall{CallID: "call", TurnID: "finished-turn", Name: wire.ToolOfferRetry, Args: json.RawMessage(`{"task":"tk1"}`)} |
| + if err := s.SendToolCall(ctx, call); err != nil { |
| + t.Fatal(err) |
| + } |
| + frames, _, err := s.Unacked(ctx, 0) |
| + if err != nil || len(frames) != 1 { |
| + t.Fatal(err, frames) |
| + } |
| + l := &Link{State: s, proto: wire.ProtocolPinnedRelease} |
| + wait := l.waitTool(call.CallID) |
| + if err := l.send(ctx, nil, frames[0]); err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case res := <-wait: |
| + if res.Code != "stuck_unsupported" { |
| + t.Fatal(res) |
| + } |
| + default: |
| + t.Fatal("no immediate unsupported result") |
| + } |
| + if frames, _, err = s.Unacked(ctx, 0); err != nil || len(frames) != 0 { |
| + t.Fatal("an old call can replay after an upgrade", frames, err) |
| + } |
| +} |
diff --git a/internal/thintest/stuck_contract_test.go b/internal/thintest/stuck_contract_test.go| index c96ec929..a7077ac2 100644 |
| --- a/internal/thintest/stuck_contract_test.go |
| +++ b/internal/thintest/stuck_contract_test.go |
| @@ -2,6 +2,7 @@ package thintest |
| import ( |
| "encoding/json" |
| + "slices" |
| "strings" |
| "testing" |
| @@ -59,3 +60,96 @@ func TestContractStatusToolHealth(t *testing.T) { |
| t.Fatalf("an invalid report believed %+v", got) |
| } |
| } |
| + |
| +// TestContractOfferRetryMerge (stuck tasks c): the coordinator cannot |
| +// merge. For a merge that failed and ended, offer_retry puts the merge |
| +// card in front of the person, asking whether to try it again; nothing is |
| +// dispatched until they tap Merge, and then the merge is theirs, decided |
| +// by the gate for them. Asked again it is the one card; nothing to offer |
| +// while a merge runs or once the branch moved. |
| +func TestContractOfferRetryMerge(t *testing.T) { |
| + r := newToolRigAt(t, wire.ProtocolCurrent) |
| + ctx := r.ctx |
| + base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) |
| + id := r.judgedTask("o", "Fix the README typo", base, cand, wire.ChecksPassed, "") |
| + m := r.dispatched(wire.SpecialistMerge, base, cand, 0) |
| + if res := r.call("o1", wire.ToolOfferRetry, map[string]string{"task": id}); !res.IsError || res.Code != "no_failed_merge" { |
| + t.Fatalf("offered while merging: %+v", res) |
| + } |
| + r.step("o-m-run", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, CandidateSHA: cand}) |
| + r.step("o-m-fail", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepFailed, Reason: "merge_failed", BaseSHA: base, CandidateSHA: cand, Termination: true}) |
| + r.wait("ready again", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageReadyToMerge }) |
| + res := r.call("o2", wire.ToolOfferRetry, map[string]string{"task": id}) |
| + if res.IsError || res.Code != "offered" || !strings.Contains(res.Text, "tap") { |
| + t.Fatalf("offer %+v", res) |
| + } |
| + if refused := r.lease(r.runner, "o-ping", wire.LeaseCheck{}); refused != "" || r.heldKinds(wire.FrameDispatch) != 0 { |
| + t.Fatalf("the offer dispatched something (%q)", refused) |
| + } |
| + k, _ := r.client.Task(ctx, id) |
| + if last := k.Steps[len(k.Steps)-1]; k.Stage != wire.StageReadyToMerge || last.Specialist != wire.SpecialistMerge || last.Attempt != 1 || last.State != wire.StepFailed { |
| + t.Fatalf("after the offer %s %+v", k.Stage, last) |
| + } |
| + var card wire.Card |
| + r.wait("retry card", func(c *Conversation) bool { |
| + for _, k := range c.Cards { |
| + if k.Kind == wire.CardMerge && k.TaskID == id && k.State == wire.CardOpen { |
| + card = k |
| + } |
| + } |
| + return card.ID != "" |
| + }) |
| + if card.Question != "Merging Fix the README typo didn’t go through. Try the merge again?" || !slices.Equal(card.Options, []string{wire.ChoiceMerge, wire.ChoiceNotNow}) { |
| + t.Fatalf("card %+v", card) |
| + } |
| + if page := r.get(r.inst.Cookie(), "/conversation", 200); !strings.Contains(page, "didn’t go through. Try the merge again?") { |
| + t.Fatal("the card is not on the page") |
| + } |
| + // Asked again: still the one card; the same call, its stored result. |
| + if again := r.call("o3", wire.ToolOfferRetry, map[string]string{"task": id}); !again.IsError || again.Code != "already_offered" { |
| + t.Fatalf("second offer %+v", again) |
| + } |
| + if same := r.call("o2", wire.ToolOfferRetry, map[string]string{"task": id}); same != res { |
| + t.Fatalf("replay %+v", same) |
| + } |
| + if n := len(r.mergeCards(id)); n != 1 { |
| + t.Fatalf("%d merge cards", n) |
| + } |
| + // The person's tap merges, as theirs. |
| + if _, err := r.client.Answer(ctx, card.ID, wire.ChoiceMerge, card.Revision); err != nil { |
| + t.Fatal(err) |
| + } |
| + _, body := r.expect(wire.FrameDispatch) |
| + if d := body.(*wire.DispatchCommand); d.Specialist != wire.SpecialistMerge || d.CandidateSHA != cand || d.Attempt != 2 { |
| + t.Fatalf("dispatch after the tap %+v", d) |
| + } |
| + if k, _ := r.client.Task(ctx, id); k.MergeDecision == nil || k.MergeDecision.DecidedBy != "person:"+Owner { |
| + t.Fatalf("decision %+v", k.MergeDecision) |
| + } |
| + m.Attempt = 2 |
| + r.mergedStep("o-m2", m, strings.Repeat("e", 40)) |
| + r.wait("done", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageDone }) |
| + if res := r.call("o4", wire.ToolOfferRetry, map[string]string{"task": id}); !res.IsError || res.Code != "task_ended" { |
| + t.Fatalf("offer on a merged task %+v", res) |
| + } |
| +} |
| + |
| +// TestContractOfferRetryOnlyWhatTheTapCanMerge: a failed merge whose |
| +// branch moved since is not offered (the tap could not merge it). |
| +func TestContractOfferRetryOnlyWhatTheTapCanMerge(t *testing.T) { |
| + r := newToolRigAt(t, wire.ProtocolCurrent) |
| + base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) |
| + id := r.judgedTask("n", "Fix the README typo", base, cand, wire.ChecksPassed, "") |
| + m := r.dispatched(wire.SpecialistMerge, base, cand, 0) |
| + r.step("n-m-fail", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepFailed, Reason: "merge_failed", BaseSHA: base, CandidateSHA: cand, Termination: true}) |
| + if err := r.runner.Send(r.ctx, "n-away", wire.FrameBranch, wire.BranchReport{TaskID: id, CandidateSHA: cand, Head: strings.Repeat("8", 40)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.wait("moved", func(c *Conversation) bool { return c.Tasks[id].NeedsYou == wire.NeedsBranchMoved }) |
| + if res := r.call("n1", wire.ToolOfferRetry, map[string]string{"task": id}); !res.IsError || res.Code != "not_mergeable" { |
| + t.Fatalf("offered with the branch away %+v", res) |
| + } |
| + if len(r.mergeCards(id)) != 0 { |
| + t.Fatal("a card was raised") |
| + } |
| +} |
diff --git a/internal/wire/frames.go b/internal/wire/frames.go| index 527b9f1a..c6d03912 100644 |
| --- a/internal/wire/frames.go |
| +++ b/internal/wire/frames.go |
| @@ -583,7 +583,7 @@ const ( |
| ) |
| // ConverseTools is the coordinator's tool set in a conversation. |
| -var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch} |
| +var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch, ToolOfferRetry} |
| // MoveInTools are the tools a move_in or explore turn may use: it looks |
| // around and takes notes, and never acts for the person. |
| @@ -676,12 +676,14 @@ var MutationKinds = map[string]string{ |
| ToolProposeSpecialist: "specialist", |
| // One research request per task in a turn, in any attempt and wording. |
| ToolResearch: "research", |
| + // One offer of a failed merge per task in a turn. |
| + ToolOfferRetry: "retry_offer", |
| } |
| // WriteTools change something outside the coordinator's session: the |
| // runner replays an exact repeat of one in a later attempt from its own |
| // record. |
| -var WriteTools = []string{ToolRequestAccess, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProjectCreated, ToolProposeSpecialist, ToolResearch} |
| +var WriteTools = []string{ToolRequestAccess, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProjectCreated, ToolProposeSpecialist, ToolResearch, ToolOfferRetry} |
| // ActivityReport is what the coordinator started doing: thinking, or a |
| // tool by name. Sent once, never acked, like a delta. |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index 3070109c..a1c77dc5 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -190,8 +190,9 @@ const ( |
| // instance offers an older runner plain Run now, with no promise. |
| ProtocolPinnedRelease = Protocol29 |
| // ProtocolStuckTasks adds the coordinator's powers for stuck tasks |
| - // (stuck.go): a hello's tool health. Below it Encode drops the tool |
| - // health (downgradeStuck). |
| + // (stuck.go): a hello's tool health and the coordinator's offer_retry. |
| + // Below it Encode drops the tool health and refuses the tool's call |
| + // (downgradeStuck). |
| ProtocolStuckTasks = Protocol30 |
| ProtocolCurrent = ProtocolStuckTasks |
| ) |
| @@ -630,7 +631,11 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| } |
| changed := false |
| if protocol < ProtocolStuckTasks { |
| - changed = downgradeStuck(body) |
| + dropped, err := downgradeStuck(body, protocol) |
| + if err != nil { |
| + return Frame{}, err |
| + } |
| + changed = dropped |
| } |
| if protocol < ProtocolPinnedRelease { |
| if v, ok := body.(*ReleaseCommand); ok && v.Connection != "" { |
diff --git a/internal/wire/stuck.go b/internal/wire/stuck.go| index 13057f8a..02012568 100644 |
| --- a/internal/wire/stuck.go |
| +++ b/internal/wire/stuck.go |
| @@ -1,12 +1,23 @@ |
| package wire |
| -import "slices" |
| +import ( |
| + "fmt" |
| + "slices" |
| +) |
| // Stuck tasks (coordinator powers, Paul 2026-11-25): ProtocolStuckTasks |
| // adds the runner's tool health to its capabilities, so the coordinator's |
| -// status can say why a preview could not be scanned. Below it Encode |
| -// drops a hello's tool health: an older instance decodes a hello |
| -// strictly and has no words for it. |
| +// status can say why a preview could not be scanned, and the |
| +// coordinator's offer_retry. Below it Encode drops a hello's tool health |
| +// and refuses the tools' calls: an older instance decodes a hello |
| +// strictly and has no words for either. |
| + |
| +// ToolOfferRetry puts a card in front of the person to try a failed merge |
| +// again; only their tap merges (the merge card's Merge). |
| +const ToolOfferRetry = "offer_retry" |
| + |
| +// StuckTools are ProtocolStuckTasks's coordinator tools. |
| +var StuckTools = []string{ToolOfferRetry} |
| // ToolHealth is whether the runner's pinned tools are installed and |
| // match their pins, one fixed state each (ToolHealthy and the rest): |
| @@ -50,10 +61,16 @@ func WithoutToolHealth(h *Hello) bool { |
| return true |
| } |
| -// downgradeStuck clears ProtocolStuckTasks's fields for an older peer. |
| -func downgradeStuck(body any) bool { |
| - if h, ok := body.(*Hello); ok { |
| - return WithoutToolHealth(h) |
| +// downgradeStuck clears ProtocolStuckTasks's fields for an older peer |
| +// and refuses its tools' calls outright. |
| +func downgradeStuck(body any, protocol int) (bool, error) { |
| + switch v := body.(type) { |
| + case *Hello: |
| + return WithoutToolHealth(v), nil |
| + case *ToolCall: |
| + if slices.Contains(StuckTools, v.Name) { |
| + return false, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, v.Name, protocol) |
| + } |
| } |
| - return false |
| + return false, nil |
| } |
diff --git a/internal/wire/stuck_test.go b/internal/wire/stuck_test.go| index 23fe4e43..0b30f073 100644 |
| --- a/internal/wire/stuck_test.go |
| +++ b/internal/wire/stuck_test.go |
| @@ -2,7 +2,9 @@ package wire_test |
| import ( |
| "bytes" |
| + "encoding/json" |
| "errors" |
| + "slices" |
| "strings" |
| "testing" |
| @@ -48,3 +50,30 @@ func TestProtocol30ToolHealth(t *testing.T) { |
| t.Fatal("WithoutToolHealth") |
| } |
| } |
| + |
| +// The stuck-task tools are coordinator write tools, held to one operation |
| +// per task in a turn, never a move-in turn's, and never sent below 30. |
| +func TestProtocol30StuckTools(t *testing.T) { |
| + for _, name := range wire.StuckTools { |
| + if !slices.Contains(wire.ConverseTools, name) || !slices.Contains(wire.WriteTools, name) || wire.MutationKinds[name] == "" || slices.Contains(wire.MoveInTools, name) { |
| + t.Fatalf("%s is not a coordinator write tool", name) |
| + } |
| + call, _ := wire.NewFrame("c", wire.FrameToolCall, wire.ToolCall{CallID: "c", TurnID: "t", Attempt: 1, Name: name, Args: json.RawMessage(`{"task":"tk"}`)}) |
| + for _, p := range []int{wire.Protocol29, wire.ProtocolAccess, wire.Protocol1} { |
| + if _, err := wire.Encode(call, p); !errors.Is(err, wire.ErrProtocol) { |
| + t.Fatalf("%s encoded at %d: %v", name, p, err) |
| + } |
| + } |
| + if same, err := wire.Encode(call, wire.Protocol30); err != nil || !bytes.Equal(same.Data, call.Data) { |
| + t.Fatalf("%s at 30: %v", name, err) |
| + } |
| + } |
| + if !slices.Contains(wire.StuckTools, wire.ToolOfferRetry) { |
| + t.Fatal("offer_retry is not a stuck-task tool") |
| + } |
| + // Any other tool call goes to an older instance as it was. |
| + other, _ := wire.NewFrame("c", wire.FrameToolCall, wire.ToolCall{CallID: "c", TurnID: "t", Attempt: 1, Name: wire.ToolReadTask, Args: json.RawMessage(`{"task":"tk"}`)}) |
| + if same, err := wire.Encode(other, wire.Protocol29); err != nil || !bytes.Equal(same.Data, other.Data) { |
| + t.Fatalf("read_task at 29: %v", err) |
| + } |
| +} |