Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

support typed agent output via StructuredOutput synthetic tool #65

Description

@yai-dev

Summary

Support typed agent output via a synthetic StructuredOutput tool.

Important Design Constraint

The current repo is TypeBox-first, not Zod-first. Any design here should align with the existing schema system used by runtime tools.

Proposed Design

  1. Extend the current agent config with an optional outputSchema
  2. Model that schema with the same schema system already used by runtime tools
  3. When present, inject a synthetic StructuredOutput tool into the runtime tool list
  4. Require the model to call it exactly once for the final answer
  5. Return validated structured output from invoke() in a typed way

Affected Areas

  • packages/core/src/agent/define-agent.ts
  • packages/core/src/agent/agent-loop.ts
  • packages/core/src/types/agent.types.ts
  • packages/core/src/types/tool.types.ts

Acceptance Criteria

  • defineAgent(...) accepts an optional schema-backed outputSchema
  • Runtime injects a synthetic structured-output tool when configured
  • Validated structured output is exposed on the final agent result
  • Behavior remains unchanged when outputSchema is absent
  • Integration tests cover both valid and invalid structured-output attempts

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestruntime-coreRelated to @agentrail/runtime-core package

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions