Skip to content

feat(acp): plumb structured output format through _meta#23294

Closed
AbhiShake1 wants to merge 1 commit intoanomalyco:devfrom
AbhiShake1:taskflow/acp-format-plumb
Closed

feat(acp): plumb structured output format through _meta#23294
AbhiShake1 wants to merge 1 commit intoanomalyco:devfrom
AbhiShake1:taskflow/acp-format-plumb

Conversation

@AbhiShake1
Copy link
Copy Markdown

What does this PR do?

Forwards the structured-output format option through the ACP prompt() handler so ACP clients (IDEs, taskflow harnesses, other ACP-speaking tools) can request structured JSON output — the same capability the SDK gained in #8161.

Before this change, the SDK honored session.prompt({ format }) but the ACP handler silently dropped it, leaving ACP clients unable to access structured output over the protocol. Motivated by the same use cases as #9320, #10456, and #5639.

Changes

  • Read params._meta?.opencode?.format in Agent.prompt(), validate it against the existing MessageV2.Format zod schema (the same one feat: support claude agent SDK-style structured outputs in the OpenCode SDK  #8161 added), and forward it to this.sdk.session.prompt({ ..., format }).
  • Echo the resulting msg.structured value back on the PromptResponse._meta as { opencode: { structured } } when the model returned structured output.
  • Uses ACP's standard _meta extension point with opencode's existing _meta.opencode.* namespacing convention (see buildVariantMeta at the same file).

How did you verify your code works?

  • bun run typecheck (tsgo --noEmit) — clean.
  • bun test test/acp/agent-interface.test.ts — 1 pass, confirming Agent still implements the ACPAgent interface.
  • Manual verification path: send an ACP prompt request with _meta: { opencode: { format: { type: "json_schema", schema: { ... } } } } and observe response._meta.opencode.structured containing the validated JSON.

Notes

  • Invalid format payloads silently fall through to plain-text mode (safeParse + optional chaining) — matches the SDK's format.optional() contract.
  • Only the non-command branch is wired; slash commands (/foo) don't consume structured output.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 18, 2026
@github-actions github-actions bot closed this Apr 18, 2026
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.

1 participant