Support structured outputs (JSON schema) per message, passed through to provider
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- java, typescript
- Ambito
- api, backend-api-design
Direzione di ricerca
Inizia dall’API sendMessage o equivalente e traccia il percorso delle opzioni per messaggio fino alle richieste dei provider OpenAI e Anthropic. Segui poi i percorsi di completamento e streaming dei messaggi dell’assistente, insieme agli hook preToolUse e agli intercettori HTTP grezzi. Il lavoro è completato quando responseFormat viene preservato, structuredOutput è esposto nel messaggio dell’assistente, i provider non supportati restituiscono un errore chiaro e i criteri di accettazione elencati sono coperti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The Copilot SDK should expose first-class support for structured outputs (JSON schema–constrained responses) when targeting model providers that natively support the feature — OpenAI (response_format: { type: "json_schema", ... }) and Anthropic (structured output / tool-schema). The schema must be settable per message and passed through unchanged to the provider.
Motivation
The primary use case is deterministic agent flows that operate on the output of Copilot Studio agents.
In Copilot Studio, an agent turn is frequently a step inside a larger orchestrated agent flow — its output is not just rendered to a user, it's fed into:
- Agent flows that expect specific fields in the output
- Routing/branching logic that switches on a category, intent, or decision
These consumers require stable, schema-validated JSON from the agent turn. Today the SDK only emits free-form assistant text, which forces every agent flow to either:
- Post-parse model prose with regex / JSON-extraction heuristics — brittle and silently breaks when the model rephrases.
- Coerce JSON via a fake single-tool tool-call — adds a round-trip per turn, pollutes tool-use telemetry, and confuses
preToolUsehooks and authoring UX. - Rewrite the outgoing HTTP body in an LLM interceptor to inject
response_format— fights the SDK's own retry/streaming logic and is unsupported.
Both OpenAI and Anthropic already accept a JSON schema directly on the request. The SDK is the only layer blocking Copilot Studio from getting deterministic agent output end-to-end.
Proposed API
Structured output must be per message, because different turns in an agent flow need different schemas (classify → plan → extract → summarize).
await session.sendMessage({
content: "Classify this support ticket.",
responseFormat: {
type: "json_schema",
schema: {
name: "TicketClassification",
strict: true,
schema: {
type: "object",
properties: {
category: { type: "string", enum: ["billing", "technical", "other"] },
priority: { type: "string", enum: ["low", "medium", "high"] },
summary: { type: "string" }
},
required: ["category", "priority", "summary"],
additionalProperties: false
}
}
}
});
Requirements
- Per-message setting —
responseFormataccepted onsendMessage/ equivalent. Optional; absent ⇒ current behavior. - Schema passthrough — Forwarded verbatim to the provider request:
- OpenAI BYOM:
response_format: { type: "json_schema", json_schema: <schema> } - Anthropic BYOM: equivalent structured output / tool-schema mechanism
- OpenAI BYOM:
- Typed result on the assistant message — Parsed JSON exposed on the resulting message (e.g.,
message.structuredOutput) so agent flows can bind to fields without re-parsing. - Streaming compatible — Final structured payload available on turn completion.
- Hook/interceptor friendly —
preToolUsehooks and raw-HTTP interceptors observe the schema in the outgoing body unchanged. - Provider capability check — Clear error if the target provider does not support structured output (rather than silently dropping the field).
Non-goals
- Inventing a new schema dialect — accept JSON Schema as the providers do.
- Cross-provider schema translation beyond what each provider natively accepts.
Acceptance criteria
-
responseFormat(JSON schema) accepted on per-message send APIs - Forwarded verbatim to OpenAI and Anthropic provider requests
- Sructured payload exposed on the resulting assistant message
- Works with streaming and with existing hook/interceptor surfaces
- Clear error when targeting a provider that doesn't support it
References
- OpenAI Structured Outputs: https://platform.openai.com/docs/guides/structured-outputs
- Anthropic structured output / tool schemas: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
- Lingua principale
- Java
- Stelle
- 10.5k
- Fork
- 1.5k
- Merge medio
- 1g 9h
- PR unite (30g)
- 131
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/copilot-sdk
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/copilot-sdk#2709 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
github/copilot-sdk#2673 ·
-
bug testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
github/copilot-sdk#2628 ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/copilot-sdk#2627 · 1 commento ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
github/copilot-sdk#2493 ·
Tutte le issue di github/copilot-sdk
Issue simili
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/flink-agents#1152 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
objectionary/eo-graphs#75 ·