feat: add ActionError for expected application-level errors#19
feat: add ActionError for expected application-level errors#19
Conversation
Action handlers can now return ActionError instead of ActionResult when encountering expected error conditions (e.g. resource not found, API quota exceeded). This bypasses output schema validation and returns the error via ResultType.ERROR, avoiding Raygun reporting for application- level errors. Closes #9. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Third-party API calls may incur charges even when the action fails. ActionError now supports cost_usd to capture these costs, matching ActionResult's billing interface. Updated billing docs, sample, and building guide to reflect this. Removed test file to keep consistent with existing repo conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a deterministic sample integration demonstrating all three result types from action handlers — ActionResult, ActionError, and unhandled exceptions — with no external service dependencies. Actions: - get_user: plain ActionResult success (or unhandled KeyError for unknown IDs) - get_user_billing: ActionResult with cost_usd - lookup_user: ActionError for unknown IDs (agent receives message as content) - lookup_user_with_cost: ActionError with cost_usd for chargeable failed lookups Useful for end-to-end testing of the ActionError flow through the lambda_wrapper → backend pipeline.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 064571c4c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
samples/api-fetch/api_fetch.py
Outdated
| """ | ||
| from autohive_integrations_sdk import ( | ||
| Integration, ExecutionContext, ActionHandler, ActionResult | ||
| Integration, ExecutionContext, ActionHandler, ActionResult, ActionError, HTTPError |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Can you check this, @NinosMan - I don't think this is a real issue in how we use integrations.
TheRealAgentK
left a comment
There was a problem hiding this comment.
LGTM @NinosMan - just one comment on the codex review feedback.
samples/api-fetch/api_fetch.py
Outdated
| """ | ||
| from autohive_integrations_sdk import ( | ||
| Integration, ExecutionContext, ActionHandler, ActionResult | ||
| Integration, ExecutionContext, ActionHandler, ActionResult, ActionError, HTTPError |
There was a problem hiding this comment.
Can you check this, @NinosMan - I don't think this is a real issue in how we use integrations.
Hamish-taylor
left a comment
There was a problem hiding this comment.
Other then Kai's comments this looks good to me
…Error - ActionError now returns ResultType.ACTION_ERROR instead of ERROR - Add VALIDATION_ERROR result type for SDK validation failures - ValidationError includes source field (input/output/legacy) - Export HTTPError from package public API
The ActionError/HTTPError changes don't belong in this sample. HTTPError can be exported when it's actually needed.
Summary
ActionErrordataclass as a return type from action handlers for expected, application-level failures (e.g. "user not found", "quota exceeded")ActionError, output schema validation is skipped and the result is returned asResultType.ACTION_ERROR(its own result type, separate from exceptions)VALIDATION_ERRORresult type so validation failures are distinct from unhandled exceptionsValidationErrornow includes asourcefield ("input", "output", or "legacy") so the backend can distinguish between bad input (expected) and bad output (bug in integration)cost_usdtoActionErrorfor when a third-party lookup incurs a charge even on failureActionErrorfrom the package public APIaction-error-demosample with deterministic actions for end-to-end testingResult types
typevalueactionActionResultaction_errorActionErrorvalidation_errorerrorTest plan
action-error-demointegrationsuccessaction returns ActionResultaction_erroraction returns ActionError as tool content (not a task failure)action_error_with_costreturns ActionError with cost_usd in billingunhandled_exceptionaction fails as infrastructure errorinput_validation_failwith bad input triggers input validation erroroutput_validation_failtriggers output validation error