Repository navigation
feat(protocol): TaskError.error_type takes model_key_budget and model_key_auth - #695
Draft
andrewpark-scaleai wants to merge 2 commits into
Draft
andrewpark-scaleai wants to merge 2 commits into
andrewpark-scaleai wants to merge 2 commits into
Conversation
…th round-trips to the platform parser Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…_key_auth An agent can now say the model endpoint refused the run's key, as out of budget or not authorized, instead of reporting it as its own agent_error. The framework already reads error_type as a string, so it accepts these from a new agent and nothing changes for an agent that keeps sending agent_error. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
andrewpark-scaleai
force-pushed
the
andrew-park/rel-agent-typed-errors
branch
from
November 16, 2026 18:04
f19f001 to
26aa29a
Compare
This branch has not been deployed
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.
Why
AgentEnv should say why every run failed, and heal itself where code can. Today a run whose model key is out of budget or rejected is blamed on the agent, because the protocol has no error type for it.
An agent reports a failed turn with
TaskResult.failure(code, message, error_type=...), anderror_typeaccepts onlyagent_errororinfra_error. A key the model endpoint refuses is neither the agent's fault nor a retryable infra failure, so readers ofPromptResponse.error_typecannot tell it apart without matching error text.What
agentenv-framework-protocol:TaskError.error_typeis now the closed typeTaskErrorType, which addsmodel_key_budgetandmodel_key_authtoagent_errorandinfra_error. The validator and every signature that took the old two-valueLiteraluse it.TaskErrorTypeis exported fromagentenv_protocol.a2a_agent.agents/AGENTS.mddocument the two values.The framework side needs no change.
TerminalResponse.from_messagealready copieserror_typefrom the data part intoPromptResponse.error_typeas a string, so it accepts the new values from a new agent, and an agent image built against an older protocol keeps sendingagent_errorexactly as today.Design decisions and tradeoffs
TaskErrorTypein the same change, so the image could not find a protocol that has it and every claude-code integration test errored. This PR now ships only the protocol and the docs. The follow-up classifies the CLI's refusal and raises the floor once a release carries this change. The tradeoff is one release of lag: until the follow-up merges, claude-code still reports a refused key asagent_error. A compatibility shim in the agent (try-import, a string fallback) would remove the lag, but it would be code that exists only to straddle one release, so I left it out.error_typevalues, not a new field. Every reader ofPromptResponse.error_typealready treats any value as "the turn errored", so verifiers keep skipping these turns. A later breaker or classifier can match the two key values exactly instead of matching text. The cost is that a reader comparingerror_type == "infra_error"will not match them. Nothing in this repo does.#698 builds on this PR and makes the framework stop retrying a step that failed with either value.
How to verify
Result: 142 passed.
test_sdk_failure_round_trips_through_platform_parsersends each new value from the protocol'sTaskResult.failurethrough the platform parser. Without the protocol change it fails withValueError: error_type must be 'agent_error' or 'infra_error'.