Skip to content

Add durable error response parts and turn resume - #390

Draft
roblourens wants to merge 4 commits into
mainfrom
roblou/agents/error-recovery-actions
Draft

Add durable error response parts and turn resume#390
roblourens wants to merge 4 commits into
mainfrom
roblou/agents/error-recovery-actions

Conversation

@roblourens

@roblourens roblourens commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Represent turn failures as durable ErrorResponsePart entries in the response stream while retaining TurnState.Error as the top-level terminal signal.
  • Let hosts mark the final error part with resumable: true; clients decide whether and how to present a resume affordance.
  • Add the client-dispatchable chat/turnResume action, which reopens the latest resumable errored turn with the same turn ID, message, response parts, and usage—without adding a synthetic message or turn.
  • Preserve prior errors when a resumed turn completes or fails again.

Semantics

The host accepts chat/turnResume only when no turn is active, the requested turn is the latest turn, that turn is errored, and its final response part is resumable. Invalid or stale resume actions are rejected before provider side effects run.

Minimal clients can ignore resumable and continue rendering a coherent terminal error. Clients that support resume can render any appropriate affordance and dispatch chat/turnResume when the user invokes it.

Validation

  • Generated documentation, schemas, action-origin metadata, and Swift, Rust, Kotlin, TypeScript, and Go protocol types.
  • npm test: 396 passing with 100% reducer branch coverage.
  • TypeScript client tests pass.
  • Go client tests pass.
  • Rust client passes cargo check --tests.

(Written by Copilot)

Represent turn errors as durable response parts with optional host-provided recovery actions. Selecting an action records the decision and reopens the same turn without adding another user message.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Represent errors as durable response parts with an optional resumable flag and add chat/turnResume to reopen the latest errored turn without a new message.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens changed the title roblou/agents/error recovery actions Add durable error response parts and turn resume Aug 11, 2026
Return no response-part identifier for durable error parts, which do not carry an id.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Pull request overview

Adds durable turn-error response parts and resumable errored turns across the protocol and generated clients.

Changes:

  • Introduces ErrorResponsePart and chat/turnResume.
  • Updates reducers and fixtures for resume eligibility and error preservation.
  • Regenerates schemas, SDK models, documentation, and changelog metadata.
Show a summary per file
File Description
types/version/registry.ts Registers the resume action for protocol 0.8.
types/test-cases/reducers/270-chat-responsepart-cannot-append-error.json Tests rejecting generic error-part appends.
types/test-cases/reducers/269-chat-turn-resume-completes-one-turn.json Tests completing a resumed turn.
types/test-cases/reducers/268-chat-turn-resume-preserves-errors-across-retries.json Tests preserving repeated errors.
types/test-cases/reducers/267-chat-turn-resume-noop-for-unresumable-error.json Tests unresumable-error rejection.
types/test-cases/reducers/266-chat-turn-resume-noop-for-nonlatest-turn.json Tests stale-turn rejection.
types/test-cases/reducers/265-chat-turn-resume-noop-for-unknown-turn.json Tests unknown-turn rejection.
types/test-cases/reducers/264-chat-turn-resume-noop-with-active-turn.json Tests active-turn rejection.
types/test-cases/reducers/263-chat-turn-resume-reopens-turn.json Tests reopening an errored turn.
types/test-cases/reducers/250-turncomplete-force-cancels-auth-required-tool-call.json Updates completed-turn expectations.
types/test-cases/reducers/240-turn-duration-is-clamped-to-zero.json Updates completed-turn expectations.
types/test-cases/reducers/161-chat-turn-lifecycle-on-chat.json Updates lifecycle expectations.
types/test-cases/reducers/107-session-input-turn-end-cleans-turn-scoped-only.json Updates finalized-turn expectations.
types/test-cases/reducers/099-endturn-force-cancels-running-tool-call.json Updates completed-turn expectations.
types/test-cases/reducers/070-full-turn-flow-with-tool-calls-and-re-confirmation.json Updates full-flow expectations.
types/test-cases/reducers/017-turncomplete-force-cancels-in-progress-tool-calls.json Updates completed-turn expectations.
types/test-cases/reducers/016-session-error-finalizes-turn-with-error.json Moves errors into response parts.
types/test-cases/reducers/015-session-turncancelled-finalizes-turn.json Removes obsolete null error state.
types/test-cases/reducers/014-session-turncomplete-finalizes-turn.json Removes obsolete null error state.
types/common/actions.ts Adds the resume action to common unions.
types/channels-chat/state.ts Defines durable error response parts.
types/channels-chat/reducer.ts Implements error finalization and resume behavior.
types/channels-chat/actions.ts Defines error and resume action contracts.
types/action-origin.generated.ts Marks resume as client-dispatchable.
scripts/generate-swift.ts Adds Swift generation metadata.
scripts/generate-rust.ts Adds Rust generation metadata.
scripts/generate-kotlin.ts Adds Kotlin generation metadata.
scripts/generate-go.ts Adds Go generation metadata.
schema/state.schema.json Adds error-part state schema.
schema/notifications.schema.json Propagates error-part definitions.
schema/errors.schema.json Propagates action and error schemas.
schema/commands.schema.json Propagates action and response schemas.
schema/actions.schema.json Defines updated chat action schemas.
docs/specification/chat-channel.md Documents recovery semantics and validation.
docs/guide/state-model.md Documents durable errors in state.
docs/guide/actions.md Lists the new resume action.
docs/.changes/20260811-error-response-parts-and-turn-resume.json Records the user-visible change.
clients/swift/AgentHostProtocol/Tests/AgentHostProtocolTests/ReducersTests.swift Tests resume dispatchability.
clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/ToolCallStateExtensions.swift Handles the new response variant.
clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Reducers.swift Implements Swift reducer behavior.
clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/State.generated.swift Regenerates Swift state models.
clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Actions.generated.swift Regenerates Swift actions.
clients/rust/crates/ahp/src/reducers.rs Implements Rust reducer behavior.
clients/rust/crates/ahp-types/src/state.rs Regenerates Rust state models.
clients/rust/crates/ahp-types/src/actions.rs Regenerates Rust actions.
clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/Reducers.kt Implements Kotlin reducer behavior.
clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/State.generated.kt Regenerates Kotlin state models.
clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/Actions.generated.kt Regenerates Kotlin actions.
clients/go/ahptypes/state.generated.go Regenerates Go state models.
clients/go/ahptypes/actions.generated.go Regenerates Go actions.
clients/go/ahp/reducers.go Implements Go reducer behavior.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 47/51 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment thread types/channels-chat/actions.ts Outdated
Comment thread types/channels-chat/state.ts Outdated
Comment thread scripts/generate-rust.ts
Comment thread types/channels-chat/reducer.ts
Tighten generic response parts to exclude errors, align resumability across generated clients, preserve the Rust error discriminator, update the Swift example, and cover completed-turn rejection.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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