Skip to main content

Functions

ok()

Create a success result.
Parameters: Returns: OkResult Example:

err()

Create an error result.
Parameters: Returns: ErrResult Example:

Types

AgentResult

Union type for handler return annotations:

OkResult

Success result dataclass:
The data field serializes to JSON over NATS. Complex objects should be dicts or lists.

ErrResult

Error result dataclass:
The error message is passed through to the host and displayed to the user.

AgentExtras

Optional metadata for success results:
Fields:
  • reasoning - Explanation of agent decisions, shown in UI for transparency
  • artifact_refs - References to created platform artifacts
  • outline_refs - Structured entries for conversation outline

ArtifactRef

Reference to a platform artifact:
Created via Friday’s /api/artifacts endpoint.

OutlineRef

Structured reference for conversation outline:

Tagged Union Pattern

OkResult and ErrResult are distinct types. It is impossible to:
  • Return success data with an error message
  • Return error data with success extras
  • Confuse the two in type checking

Serialisation

Results serialize to a JSON envelope over NATS:
AgentExtras is serialized separately and merged by the host.

Best Practices

  • Return structured data - Dicts with clear field names, not raw strings
  • Provide reasoning - Helps users understand agent decisions
  • Create artifacts for large outputs - Persist reports, analyses, generated code
  • Use outline_refs for scannable results - Helps navigate complex outputs
  • Handle errors early - Validate ctx.env, check capabilities, return err() with clear messages

Common Error Messages

See Also

How to Stream Progress

Real-time updates during execution