feat(sdk/go): Agent.Pause webhook approvals, harness cost reporting, incremental schema mode#744
Merged
Conversation
Parity with the Python SDK's Agent.pause(): PauseManager registers a pending approval before client.RequestApproval transitions the execution to waiting, then blocks until the control plane's /webhooks/approval callback resolves it (or expiry/cancellation). Route matches the Python agent_server path and the CP's notifyApprovalCallback payload; exempted from origin/DID middleware like other CP-to-worker notifications. PauseClock intentionally not ported: the Go SDK has no execution watchdog to discount. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Metrics/Result gain CostUSD (*float64, nil = unknown) extracted from Claude's JSON output with Python's cost_usd-or-total_cost_usd semantics and accumulated across retries including failed attempts. Options gains SchemaMode (single/incremental/auto): auto engages on the compact-encoded schema crossing the large-schema token threshold, with the incremental prompt suffix, per-field failure diagnosis, and followup prompts ported byte-verbatim from the Python SDK. Non-Claude providers report nil cost (Python parity when litellm is unavailable). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Performance
✓ No regressions detected |
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
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
Closes three Go SDK parity gaps with the Python SDK, found while porting SWE-AF to Go:
Agent.Pause()with webhook-resumed approvals —PauseManager+/webhooks/approvalroute (same path and payload contract as the Pythonagent_serverroute; verified against the control plane'snotifyApprovalCallback). Registers the pending approval beforeRequestApprovaltransitions the execution towaiting, then blocks until webhook resolution, expiry, or ctx cancellation. The route is exempted from origin/DID middleware like other CP→worker notifications.PauseClockis intentionally not ported: the Go SDK has no execution watchdog whose budget it would discount.cost_usd—Metrics.CostUSD/Result.CostUSD(*float64, nil = unknown) extracted from Claude's JSON output with Python'scost_usd or total_cost_usdsemantics, accumulated across retries including failed attempts. Non-Claude providers report nil (matching Python when litellm is unavailable; their CLIs emit no structured cost).SchemaMode(single/incremental/auto) — ports the Python incremental structured-output recovery: auto engages when the compact-encoded schema crosses the large-schema token threshold; incremental prompt suffix, per-field failure diagnosis, and followup prompts are byte-verbatim from_schema.py.Test plan
go mod tidyno diff;go build ./...,go vet ./...cleango test ./...— all packages green; pause tests race-clean (-race);pause.gocoverage 91.4% (above the repo coverage gates)httptestagainst the agent mux: decision mapping (approved/rejected/request_changes/expired), execution-id fallback, concurrent pause independence, middleware bypassConsumer: the SWE-AF Go port (Agent-Field/SWE-AF#94) swaps its poll-based HITL workaround to
Agent.Pause()on top of this.🤖 Generated with Claude Code