Skip to content

Support for structured outputs in agent loop and improvements in clients#466

Merged
adamw merged 11 commits intomasterfrom
436-add-support-for-structured-outputs-in-agent-loop
May 7, 2026
Merged

Support for structured outputs in agent loop and improvements in clients#466
adamw merged 11 commits intomasterfrom
436-add-support-for-structured-outputs-in-agent-loop

Conversation

@kubinio123
Copy link
Copy Markdown
Contributor

@kubinio123 kubinio123 commented May 5, 2026

DONE:

  • Support for structured output in agent core:
    • Add ResponseSchema[T] for structured responses instead of plain text
    • Agent.runAs[T] returning AgentResult[Either[AgentParseError, T]]
    • Update the system prompt to instruct the model to call finish with a JSON payload matching the response schema
  • Utilities in clients:
    • Typed chat helpers for using structured output (tapir schemas + upickle)

I think this solves the #436.

However #206 is still a valid idea to explore; less explicit approach relying solely on meta programming. I think that can still be a subject to some POC 🤔

@kubinio123 kubinio123 linked an issue May 5, 2026 that may be closed by this pull request
@kubinio123 kubinio123 changed the title Support for structured outputs Support for structured outputs in agent loop and improvements in clients May 5, 2026
@kubinio123 kubinio123 marked this pull request as ready for review May 5, 2026 12:54
@kubinio123 kubinio123 requested a review from adamw May 5, 2026 12:54
private def buildSystemPrompt(maxIterations: Int, structuredFinish: Boolean): String = {
val structuredAddendum =
if (structuredFinish)
"\n\nWhen calling the finish tool, you MUST pass a JSON object matching the provided input schema for the final answer."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't this be - the provided output schema?

finally backend.close()
}

object TypedAgentLoopExample extends App {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe this should be a separate example file

@kubinio123
Copy link
Copy Markdown
Contributor Author

Thanks, pushed the updates ✔️

@adamw adamw merged commit a832636 into master May 7, 2026
10 checks passed
@adamw adamw deleted the 436-add-support-for-structured-outputs-in-agent-loop branch May 7, 2026 09:22
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.

Add support for structured outputs in Agent Loop

2 participants