Skip to content

feat: add ActionError for expected application-level errors#19

Open
NinosMan wants to merge 7 commits intomasterfrom
na/strange-goldstine
Open

feat: add ActionError for expected application-level errors#19
NinosMan wants to merge 7 commits intomasterfrom
na/strange-goldstine

Conversation

@NinosMan
Copy link
Contributor

@NinosMan NinosMan commented Mar 17, 2026

Summary

  • Adds ActionError dataclass as a return type from action handlers for expected, application-level failures (e.g. "user not found", "quota exceeded")
  • When a handler returns ActionError, output schema validation is skipped and the result is returned as ResultType.ACTION_ERROR (its own result type, separate from exceptions)
  • Adds VALIDATION_ERROR result type so validation failures are distinct from unhandled exceptions
  • ValidationError now includes a source field ("input", "output", or "legacy") so the backend can distinguish between bad input (expected) and bad output (bug in integration)
  • Adds optional cost_usd to ActionError for when a third-party lookup incurs a charge even on failure
  • Exports ActionError from the package public API
  • Adds action-error-demo sample with deterministic actions for end-to-end testing

Result types

type value When Agent sees
action Handler returns ActionResult Success content
action_error Handler returns ActionError Error message as content (not a task failure)
validation_error SDK schema validation fails Tool execution error
error Unhandled exception Tool execution error

Test plan

  • Deploy action-error-demo integration
  • success action returns ActionResult
  • action_error action returns ActionError as tool content (not a task failure)
  • action_error_with_cost returns ActionError with cost_usd in billing
  • unhandled_exception action fails as infrastructure error
  • input_validation_fail with bad input triggers input validation error
  • output_validation_fail triggers output validation error
  • Old integrations (e.g. hackernews) continue to work with both old and new lambda wrapper

NinosMan and others added 3 commits March 18, 2026 09:43
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.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

"""
from autohive_integrations_sdk import (
Integration, ExecutionContext, ActionHandler, ActionResult
Integration, ExecutionContext, ActionHandler, ActionResult, ActionError, HTTPError

This comment was marked as resolved.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check this, @NinosMan - I don't think this is a real issue in how we use integrations.

Copy link
Collaborator

@TheRealAgentK TheRealAgentK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @NinosMan - just one comment on the codex review feedback.

"""
from autohive_integrations_sdk import (
Integration, ExecutionContext, ActionHandler, ActionResult
Integration, ExecutionContext, ActionHandler, ActionResult, ActionError, HTTPError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check this, @NinosMan - I don't think this is a real issue in how we use integrations.

Copy link
Contributor

@Hamish-taylor Hamish-taylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
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.

3 participants