Commit bcbdcf5
committed
docs(spec+plan): session-aware structured output for agent.session.send
Two-file pair documenting the design and implementation of an optional
responseSchema parameter on AgentSession.send that routes through each
provider's native structured-output API while preserving session memory:
- OpenAI: response_format: { type: 'json_schema', json_schema: { ... } }
- Anthropic: forced tool-use (single tool with input_schema, tool_choice forced)
- Gemini: responseMimeType + responseSchema in generationConfig
- OpenRouter / unknown: degrades to json_object (no schema enforcement)
Existing agentos plumbing already partially in place: generateText
already passes _responseFormat through to providers, OpenAIProvider
already forwards the OpenAI shape verbatim (line 662), AnthropicProvider
already builds tool_choice (line 848), GeminiProvider already maps
json_object to responseMimeType (line 732). What's missing is exposing
this on session.send (currently text-only) plus per-provider routing
of schema-bearing payloads.
Motivation: paracosm's commander/department/judge calls fail schema
validation 3x in a row on gpt-5.4-mini and fall back to the literal
"Commander decision unavailable; defer to department consensus" text
in stored artifacts. With native enforcement the retry loop becomes
dead code.
Plan is 6 tasks + verification, ~315 lines of source + tests across
5 files, fully backward-compatible. No breaking change to any
existing API.1 parent f7ecef3 commit bcbdcf5
2 files changed
Lines changed: 1142 additions & 0 deletions
File tree
- docs/superpowers
- plans
- specs
0 commit comments