feat(core): define a stable agent-facing error contract #498
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.46) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 467 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.368
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #498"
general
weight: 0.35
abhijeet-dhumal
Description
Eight failure paths returned a plain dict instead of the shared
ToolErrorshape, so a client reading the structured body could not rely onsuccessbeing present, and in two caseserror_codewas missing too. All eight now returnToolError(...).model_dump().| Path | Location | Code |
|------|----------|------|
| Rate limiter rejected the call |
_audit_wrap,core/server.py|RATE_LIMITED|| Breaker open for the tool |
_audit_wrap,core/server.py|CIRCUIT_OPEN|| Tool name not registered |
execute_tool,core/dynamic_tools.py|TOOL_NOT_FOUND|| Arguments do not bind to the signature |
execute_tool,core/dynamic_tools.py|VALIDATION_ERROR|| Breaker open inside
execute_tool|execute_tool,core/dynamic_tools.py|CIRCUIT_OPEN|| Wrapped tool raised |
execute_tool,core/dynamic_tools.py|SDK_ERROR|| Too many names for
describe_tools|core/dynamic_tools.py|VALIDATION_ERROR|| Query over
MAX_QUERY_LENGTH|find_tools,core/dynamic_tools.py|VALIDATION_ERROR|The first six are the ones @abhishekKokadwar measured on main. The last two have the same defect, so they are included here.
Also:
ErrorCode.TOOL_NOT_FOUND, sinceRESOURCE_NOT_FOUNDmeans a missing Kubernetes resource and should not be overloaded.RETRIABLE_ERROR_CODES,CALLER_ERROR_CODESandis_retriable_error(), so the retry vs correct input vs ask permission decision is machine-readable rather than inferred from the code name.ToolError.tool, optional, set when a wrapper reports the failure. Keeps the existingtoolkey on theexecute_toolpaths.execute_toolexception path logs WARNING withexc_infoand carries structured context indetailsviaexception_details(). Tracebacks stay DEBUG-only.docs/design/error-contract.mddocuments the shape and the code table.CONVENTIONS.mdpoints at it.One choice worth a reviewer's eye: the retriable set is not
is_infrastructure_error().RATE_LIMITEDandCIRCUIT_OPENare worth retrying from the client side but must not count as breaker failures, or the breaker feeds on its own output.Additive for current clients: no success-path shape changed, no code renamed or removed.
Related Issue
Fixes #309
#338 rewrites the breaker lines in
execute_tool, which two of these changes touch. Happy to rebase onto it whenever it lands.Checklist
make test-python)make verify)git commit -s)Testing
kubeflow_mcp/core/error_contract_test.pyadds one test per path, each assertingsuccess is False, a documented code, a non-empty safe message, and no traceback in the response. A final test asserts a successful call is untouched.Full suite: 1178 passed, 8 skipped.
ruff checkandruff format --checkclean.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Errors now include consistent success status and stable error codes, making failures easier to identify and handle.
Responses provide clearer recovery hints for unavailable tools and invalid arguments.
Error responses identify the affected tool and indicate which failures may be retried.
Documentation
Added guidance on error response formats, retry behavior, and handling different types of errors.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->