graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(providers): Gemini on Google's Interactions API
Rach Pradhance7a25354497
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bc4c46ac..3871f77e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,30 @@ The release workflow uses a tag's section here as its release notes (ahand-written `docs/releases/<tag>.md` wins if present), so keeping this filecurrent is part of cutting a release.+## Unreleased++- Gemini is a first-class provider, on Google's own Interactions API.+ `GEMINI_API_KEY` serves `gemini-*` directly instead of falling through+ to the gateway as an uncatalogued model, and `graff --model+ gemini-3.8-flash` picks it up. This is a fourth wire format beside+ Anthropic Messages, OpenAI chat, and OpenAI Responses: a turn POSTs one+ Interaction and reads back execution steps (thought / model_output /+ function_call), with its own `step.start`/`step.delta` event stream.+- Gemini keeps its real context window. Uncatalogued, it inherited the+ conservative 200k default and auto-compacted at 160k -- on a+ 1,048,576-token model, which compacts near 838k now.+- Fixed two crashes found while wiring it up, both of which took down the+ whole process rather than reporting an error: the response root was+ dereferenced as an object, which a top-level JSON array (how Google's+ compatibility layer returns errors) turned into a panic; and streamed+ `extra_content` was stored pointing into the per-request scratch arena+ that is reset before the next request, so the session held freed memory+ and walked it on the following turn.+- A harness-authored note (budget landing, repair grant, empty-completion+ bounce, compaction handoff) now follows the wire's shape. Interactions+ rejects a bare `{"role":"user"}` entry, so those notes ended the turn+ with a 400.+## v0.0.287 (2026-09-04)- The macOS desktop app updates itself. It compares the newest releasediff --git a/examples/edge-worker/src/remote.ts b/examples/edge-worker/src/remote.tsindex 230920bb..d738f403 100644--- a/examples/edge-worker/src/remote.ts+++ b/examples/edge-worker/src/remote.ts@@ -9,9 +9,9 @@export const HARNESS_VERSION = "0.12";-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemma-4-31b" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "learn_candidate" | "peer_message" | "workspace" | "imagegen";-export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";+export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";/** Events streamed by the bridge (same `--json` contract as the stdio SDK).* `seq` is a monotonic, gap-free, 1-based per-session id the bridge forwards@@ -521,5 +521,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat}}-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemma-4-31b", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "peer_message", "workspace", "imagegen"];diff --git a/lean-proofs/Graff/Provider.lean b/lean-proofs/Graff/Provider.leanindex 195b39bb..5223bf5e 100644--- a/lean-proofs/Graff/Provider.lean+++ b/lean-proofs/Graff/Provider.lean@@ -48,6 +48,7 @@ def specs : List Row :=, { id := "codegraff", kind := .openai, auth := .bearer, login := .codegraffDevice, catalog := .openai, takesEffort := true }, { id := "deepseek", kind := .openai, auth := .bearer, takesEffort := true }, { id := "openai", kind := .responses, auth := .bearer }+ , { id := "google", kind := .interactions, auth := .googApiKey, catalog := .openai, takesEffort := true }, { id := "minimax", kind := .anthropic, auth := .bearer }, { id := "xiaomi", kind := .openai, auth := .bearer }, { id := "kilo", kind := .openai, auth := .bearer }@@ -83,7 +84,7 @@ def xApiKeyCount : Nat := countWhere (fun r => r.auth == .xApiKey) specsdef providerRows : Nat := specs.length-theorem provider_cube : providerRows = 21 := by native_decide+theorem provider_cube : providerRows = 22 := by native_decidetheorem responses_vendors : responsesCount = 2 := by native_decidetheorem one_x_api_key : xApiKeyCount = 1 := by native_decidediff --git a/lean-proofs/Graff/Transport.lean b/lean-proofs/Graff/Transport.leanindex 345be83f..9c840da7 100644--- a/lean-proofs/Graff/Transport.lean+++ b/lean-proofs/Graff/Transport.lean@@ -22,11 +22,15 @@ inductive Kind where| anthropic| openai| responses+ /-- Google Interactions: execution steps, never WS-eligible. -/+ | interactionsderiving DecidableEq, Repr, BEqinductive Auth where| xApiKey| bearer+ /-- Google's `x-goog-api-key`; rejected as an OAuth bearer. -/+ | googApiKeyderiving DecidableEq, Repr, BEqinductive Pipe wherediff --git a/scripts/eval/tier1-manifest.json b/scripts/eval/tier1-manifest.jsonindex 69441a07..096c1bba 100644--- a/scripts/eval/tier1-manifest.json+++ b/scripts/eval/tier1-manifest.json@@ -15,7 +15,7 @@"src/repl.zig","TUI/root.zig"],- "test_count_baseline": 1909,+ "test_count_baseline": 1942,"test_count_slack": 25,"required_invariants": [{diff --git a/sdk/py/harness_sdk.py b/sdk/py/harness_sdk.pyindex a8272b03..230c9eb4 100644--- a/sdk/py/harness_sdk.py+++ b/sdk/py/harness_sdk.py@@ -13,9 +13,9 @@ import urllib.errorimport urllib.requestfrom typing import Iterator, List, Literal, Optional, TypedDict, Union-MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemma-4-31b", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"]+MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"]TOOLS = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "peer_message", "workspace", "imagegen"]-PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "minimax", "xiaomi", "kilo", "groq", "cerebras", "mistral", "kimi", "moonshot", "xai", "zai", "vercel", "openrouter", "fugu", "fireworks", "mlx", "lmstudio", "codex"]+PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "google", "minimax", "xiaomi", "kilo", "groq", "cerebras", "mistral", "kimi", "moonshot", "xai", "zai", "vercel", "openrouter", "fugu", "fireworks", "mlx", "lmstudio", "codex"]class ImageUrlInput(TypedDict):diff --git a/sdk/ts/harness.ts b/sdk/ts/harness.tsindex f75864c4..67593118 100644--- a/sdk/ts/harness.ts+++ b/sdk/ts/harness.ts@@ -11,9 +11,9 @@ import type { Readable, Writable } from "node:stream";export const HARNESS_VERSION = "0.12";-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemma-4-31b" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "learn_candidate" | "peer_message" | "workspace" | "imagegen";-export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";+export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";/** Events streamed by `harness --json` (one JSON object per stdout line), each* discriminated by `type` — the analogue of codegraff's AgentEvent stream.@@ -674,5 +674,5 @@ export async function* runAgent(opts: RunAgentOptions): AsyncGenerator<Event> {}}-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemma-4-31b", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "peer_message", "workspace", "imagegen"];diff --git a/sdk/ts/remote.ts b/sdk/ts/remote.tsindex 230920bb..d738f403 100644--- a/sdk/ts/remote.ts+++ b/sdk/ts/remote.ts@@ -9,9 +9,9 @@export const HARNESS_VERSION = "0.12";-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemma-4-31b" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "openai/gpt-oss-120b" | (string & {});export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "learn_candidate" | "peer_message" | "workspace" | "imagegen";-export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";+export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";/** Events streamed by the bridge (same `--json` contract as the stdio SDK).* `seq` is a monotonic, gap-free, 1-based per-session id the bridge forwards@@ -521,5 +521,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat}}-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemma-4-31b", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "openai/gpt-oss-120b"];export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "peer_message", "workspace", "imagegen"];diff --git a/spec/conformance.py b/spec/conformance.pyindex 0d51a38e..9f2cfb0f 100644--- a/spec/conformance.py+++ b/spec/conformance.py@@ -317,8 +317,8 @@ def check_provider() -> int:ids = [r["id"] for r in PROVIDER_SPECS]if len(ids) != len(set(ids)):raise Counterexample("provider-unique", None, f"ids={ids}")- if len(PROVIDER_SPECS) != 21:- raise Counterexample("provider-count", None, f"n={len(PROVIDER_SPECS)} want=21")+ if len(PROVIDER_SPECS) != 22:+ raise Counterexample("provider-count", None, f"n={len(PROVIDER_SPECS)} want=22")responses = [r for r in PROVIDER_SPECS if r["kind"] == "responses"]if [r["id"] for r in responses] != ["openai", "codex"]:raise Counterexample("responses-vendors", None, f"{responses}")diff --git a/spec/kernels/providers.json b/spec/kernels/providers.jsonindex 0177befa..b8e7ebf7 100644--- a/spec/kernels/providers.json+++ b/spec/kernels/providers.json@@ -38,6 +38,15 @@"sub_login": false,"takes_effort": false},+ {+ "id": "google",+ "kind": "interactions",+ "auth": "goog_api_key",+ "login": "api_key",+ "catalog": "openai",+ "sub_login": false,+ "takes_effort": true+ },{"id": "minimax","kind": "anthropic",diff --git a/spec/ref/provider.py b/spec/ref/provider.pyindex e157f210..929ab719 100644--- a/spec/ref/provider.py+++ b/spec/ref/provider.py@@ -4,8 +4,8 @@ from __future__ import annotationsfrom typing import Literal-Kind = Literal["anthropic", "openai", "responses"]-Auth = Literal["x_api_key", "bearer"]+Kind = Literal["anthropic", "openai", "responses", "interactions"]+Auth = Literal["x_api_key", "bearer", "goog_api_key"]Login = Literal["api_key", "codegraff_device", "codex_device", "kimi_device", "xai_device"]Catalog = Literal["baked", "codex", "kimi", "openai", "anthropic"]@@ -35,6 +35,7 @@ SPECS: list[dict] = [row("codegraff", "openai", "bearer", login="codegraff_device", catalog="openai", takes_effort=True),row("deepseek", "openai", "bearer", takes_effort=True),row("openai", "responses", "bearer"),+ row("google", "interactions", "goog_api_key", catalog="openai", takes_effort=True),row("minimax", "anthropic", "bearer"),row("xiaomi", "openai", "bearer"),row("kilo", "openai", "bearer"),diff --git a/spec/ref/transport.py b/spec/ref/transport.pyindex 014e9f23..767f04a3 100644--- a/spec/ref/transport.py+++ b/spec/ref/transport.py@@ -7,7 +7,7 @@ from itertools import productfrom pathlib import Pathfrom typing import Literal-Kind = Literal["anthropic", "openai", "responses"]+Kind = Literal["anthropic", "openai", "responses", "interactions"]Pipe = Literal["ws", "sse"]KINDS: tuple[Kind, ...] = ("anthropic", "openai", "responses")Event = tuple # ("setKind", kind) | ("markSub",) | ("joinRoot",) | ("setCodexWs", bool) | ...diff --git a/src/agent.zig b/src/agent.zigindex 0bc891b5..af3c7232 100644--- a/src/agent.zig+++ b/src/agent.zig@@ -175,6 +175,7 @@ pub const Agent = struct {tools_anthropic: []const u8 = schema.tools_anthropic_sub,tools_openai: []const u8 = schema.tools_openai_sub,tools_responses: []const u8 = schema.tools_responses_sub,+ tools_interactions: []const u8 = @import("schema_interactions.zig").tools_interactions_sub,todos: std.ArrayList(TodoItem) = .empty,eval_cmd: ?[]const u8 = null, // --eval: shell command that scores the current output (eval-driven loop)eval_target: u8 = 90, // --until: stop when the score reaches this (0-100)@@ -293,6 +294,7 @@ pub const Agent = struct {self.tools_anthropic = "";self.tools_openai = "";self.tools_responses = "";+ self.tools_interactions = "";}pub noinline fn ensureModelCatalog(self: *Agent, keys: provider_mod.Keys) void {@@ -388,11 +390,7 @@ pub const Agent = struct {}const hist_len = self.messages.items.len;const root = try self.request(if (self.text_only) null else self.toolsJson());- const done = switch (self.provider.kind) {- .anthropic => try self.stepAnthropic(root),- .openai => try self.stepOpenAI(root),- .responses => try self.stepResponses(root),- };+ const done = try @import("agent_steps.zig").stepForWire(self, root);if (done) |final_text| {// A completion with no text and no tool calls used to end the turn// silently — mid-task that just looks like a dead session.diff --git a/src/agent_argstream.zig b/src/agent_argstream.zigindex cbe90cf4..ebda9ae8 100644--- a/src/agent_argstream.zig+++ b/src/agent_argstream.zig@@ -269,6 +269,11 @@ pub fn argLiveDelta(self: *Agent, obj: std.json.ObjectMap) void {const ui = !main_mod.json_mode and !self.stream_quiet;if (!ui and !rlm_spec.available) return;switch (self.provider.kind) {+ // Interactions streams arguments as `arguments_delta` chunks keyed by+ // step index rather than the per-wire shapes this extractor models.+ // The live argument preview is simply not rendered there; the call is+ // still dispatched in full from the assembled step.+ .interactions => return,.anthropic => {const t = obj.get("type") orelse return;if (t != .string) return;diff --git a/src/agent_catalog.zig b/src/agent_catalog.zigindex d2570e89..907f3778 100644--- a/src/agent_catalog.zig+++ b/src/agent_catalog.zig@@ -36,6 +36,7 @@ fn slot(self: *const Agent) []const u8 {.anthropic => self.tools_anthropic,.openai => self.tools_openai,.responses => self.tools_responses,+ .interactions => self.tools_interactions,};}@@ -45,6 +46,7 @@ pub fn ensureRootTools(self: *Agent, kind: Provider.Kind) !void {.anthropic => &self.tools_anthropic,.openai => &self.tools_openai,.responses => &self.tools_responses,+ .interactions => &self.tools_interactions,};if (dest.*.len != 0) return;const specs = if (self.sub)diff --git a/src/agent_compact.zig b/src/agent_compact.zigindex 1a4d1770..497e1992 100644--- a/src/agent_compact.zig+++ b/src/agent_compact.zig@@ -55,6 +55,9 @@ pub fn summaryResponseComplete(self: *Agent, root: std.json.ObjectMap) bool {if (root.get("incomplete")) |value| if (value == .bool and value.bool) return false;return switch (self.provider.kind) {.responses => true, // parseResponses marks incomplete/missing terminals above+ // The assembler only emits a status when it saw interaction.completed;+ // a truncated stream is already flagged via root.incomplete above.+ .interactions => true,.anthropic => blk: {// Raw non-streaming compatibility gateways may omit stop_reason.// Stream reassembly marks that same absence as root.incomplete, so@@ -217,7 +220,7 @@ pub fn compact(self: *Agent) anyerror!usize {}var fresh = std.json.Array.init(self.arena);- try fresh.append(try textMessage(self.arena, "user", try handoffMessage(self, summary, live_messages.items[0..recent_start])));+ try fresh.append(try @import("messages.zig").userNote(self.arena, self.provider.kind, try handoffMessage(self, summary, live_messages.items[0..recent_start])));// Preserve a valid recent suffix verbatim (up to ~8k estimated tokens),// including its user boundary and paired tool calls/results.try peer_context.appendWorkingSet(&fresh, recent_messages, live_messages.items);diff --git a/src/agent_context.zig b/src/agent_context.zigindex 8a83bcc7..7128628e 100644--- a/src/agent_context.zig+++ b/src/agent_context.zig@@ -118,6 +118,9 @@ pub fn recordUsage(self: *Agent, root: std.json.ObjectMap, req_body_len: usize)if (usage != .object) return floorContextTokens(self, fallback);const u = usage.object;switch (self.provider.kind) {+ // Interactions reports one flat set of totals; total_input_tokens+ // already includes the cached portion that total_cached_tokens names.+ .interactions => @import("interactions_steps.zig").recordUsage(self, u, fallback),.anthropic => {var total: i64 = 0;const fields = [_][]const u8{@@ -156,15 +159,14 @@ pub fn recordUsage(self: *Agent, root: std.json.ObjectMap, req_body_len: usize)if (cache > 0) self.last_cache_read = @intCast(cache);self.recordCost(@max(usageInt(u, "prompt_tokens") - cache - cache_write, 0), cache, cache_write, usageInt(u, "completion_tokens"));},- // codex uses recordUsageResponses on its own path.- .responses => {},+ .responses => {}, // codex uses recordUsageResponses on its own path.}}/// #202: floor the context meter at the local estimate (full-input byte/4, or the/// request-body byte/4 when the history isn't serialized yet) when the API omits/// usage, so auto-compaction still triggers. Never lowers an existing higher count.-fn floorContextTokens(self: *Agent, est: u64) void {+pub fn floorContextTokens(self: *Agent, est: u64) void {const estimate = self.contextEstimate();self.last_context_tokens = @max(estimate.effective, @max(estimate.local, est));self.context_local_tokens = estimate.local;@@ -173,7 +175,7 @@ fn floorContextTokens(self: *Agent, est: u64) void {/// A full-history request's nonzero provider usage is authoritative enough to/// correct a stale high meter after an explicit trim/provider mutation. Still/// retain the complete local request estimate as a structural lower bound.-fn replaceContextTokens(self: *Agent, reported: u64) void {+pub fn replaceContextTokens(self: *Agent, reported: u64) void {const local = self.fullRequestEstimateTokens();self.last_context_tokens = @max(local, reported);self.context_local_tokens = local;diff --git a/src/agent_empty_completion.zig b/src/agent_empty_completion.zigindex 8e5743f4..46eed76d 100644--- a/src/agent_empty_completion.zig+++ b/src/agent_empty_completion.zig@@ -46,7 +46,7 @@ pub fn handle(self: *Agent, final_text: []const u8, hist_len: usize) !bool {}if (!shouldBounce(main_mod.unattended, no_local_tools.lean, self.text_only, self.review_mode, self.sub, self.tool_calls_this_turn, self.model_calls_this_turn, final_text))return false;- try self.messages.append(try messages.textMessage(self.arena, "user", bounce_note));+ try self.messages.append(try messages.userNote(self.arena, self.provider.kind, bounce_note));try self.say("[described a change with no tool call — asking once more]\n", .{});if (self.tracer) |tr| tr.note("fake_done", "lean -p text-only; bounced");return true;diff --git a/src/agent_overflow.zig b/src/agent_overflow.zigindex 144ce5c9..e047c2e5 100644--- a/src/agent_overflow.zig+++ b/src/agent_overflow.zig@@ -215,6 +215,21 @@ fn nonNegative(n: i64) u64 {pub fn readCompletion(kind: Provider.Kind, root: std.json.ObjectMap) Completion {var c: Completion = .{};return switch (kind) {+ // Interactions reports totals under its own names, and any step other+ // than a bare thought counts as content the turn actually produced.+ .interactions => {+ if (usageOf(root)) |u| {+ c.input_tokens = nonNegative(usageInt(u, "total_input_tokens"));+ c.output_tokens = nonNegative(usageInt(u, "total_output_tokens") +| usageInt(u, "total_thought_tokens"));+ }+ if (str(root, "status")) |s| c.stop = stopFromString(kind, s);+ if (arr(root, "steps")) |steps| for (steps.items) |st| {+ if (st != .object) continue;+ const t = str(st.object, "type") orelse continue;+ if (!std.mem.eql(u8, t, "thought")) c.has_content = true;+ };+ return c;+ },.anthropic => {if (usageOf(root)) |u| {c.input_tokens = nonNegative(usageInt(u, "input_tokens") +|diff --git a/src/agent_request.zig b/src/agent_request.zigindex e27754b9..f6447e45 100644--- a/src/agent_request.zig+++ b/src/agent_request.zig@@ -112,7 +112,7 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {if (self.run_budget) |b| if (budget_permit) |p| {if (b.max_model_calls != 0 and p.call_number == b.max_model_calls and tools != null) {tools = null;- try self.messages.append(try wire_messages.textMessage(self.arena, "user", landing_note));+ try self.messages.append(try wire_messages.userNote(self.arena, self.provider.kind, landing_note));if (self.tracer) |tr| tr.note("budget", "final call: tools withheld so the run lands its answer (#390)");}};@@ -472,7 +472,21 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {try self.sayApiError("unparseable response: {s}", .{resp_body[0..@min(resp_body.len, 400)]});return error.ApiError;};- const root = resp.object;+ // Google's OpenAI-compat layer wraps its error envelope in a ONE-ELEMENT+ // ARRAY ([{"error":{…}}]). An unchecked `.object` here took down the+ // whole process on a response every other provider reports as an error,+ // so unwrap that shape and refuse any other non-object root cleanly.+ const root = switch (resp) {+ .object => |o| o,+ .array => |a| if (a.items.len == 1 and a.items[0] == .object) a.items[0].object else {+ try self.sayApiError("unexpected response shape: {s}", .{resp_body[0..@min(resp_body.len, 400)]});+ return error.ApiError;+ },+ else => {+ try self.sayApiError("unexpected response shape: {s}", .{resp_body[0..@min(resp_body.len, 400)]});+ return error.ApiError;+ },+ };if (root.get("type")) |t| if (t == .string and std.mem.eql(u8, t.string, "error")) {const eo = if (root.get("error")) |ev| (if (ev == .object) ev.object else null) else null;diff --git a/src/agent_request_body.zig b/src/agent_request_body.zigindex 091d837c..40d22be0 100644--- a/src/agent_request_body.zig+++ b/src/agent_request_body.zig@@ -172,9 +172,7 @@ pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream:// Sticky cache partition. Same value as x-grok-conv-id (xAI// official maximize-hits). Root is the project id; children// share a role lane so sibling scouts reuse system+tools.- var ckbuf: [96]u8 = undefined;- try s.objectField("prompt_cache_key");- try s.write(http_headers.requestCacheKey(self.io, self.label, self, self.provider.id, &ckbuf));+ try http_headers.writeRequestCacheKey(&s, self.io, self.label, self, self.provider.id);// reasoning_effort (codegraff/deepseek/zai) + Z.AI thinking + Vercel reasoning.effort.try @import("zai_wire.zig").writeChatExtras(&s, self.provider.id, self.provider.model, self.sendReasoningEffort(), @import("effort_route.zig").wireEffort(self.provider.model, @tagName(self.reasoning)));// --output-schema: structured outputs (xAI docs' response_format).@@ -195,6 +193,8 @@ pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream:// The Responses-wire body (codex / xAI / native Codegraff) lives in its own module// under the 600-line ceiling; structured-output writers ride along..responses => try @import("agent_request_body_responses.zig").write(self, &s, tools, force_tool),+ // Google Interactions: execution steps, not messages or items.+ .interactions => try @import("interactions_wire.zig").write(self, &s, tools, force_tool, stream),}try s.endObject();return aw.toOwnedSlice();diff --git a/src/agent_steps.zig b/src/agent_steps.zigindex 0c10afd0..b8a761e5 100644--- a/src/agent_steps.zig+++ b/src/agent_steps.zig@@ -15,7 +15,7 @@ const main_mod = @import("main.zig");const agent_mod = @import("agent.zig");const tools_mod = @import("tools.zig");const Agent = agent_mod.Agent;-const ToolCall = tools_mod.ToolCall;+pub const ToolCall = tools_mod.ToolCall;const messages_mod = @import("messages.zig");const util = @import("util.zig");@@ -24,7 +24,7 @@ const codex_chain = @import("codex_chain.zig");const toolResultMessage = messages_mod.toolResultMessage;const turn_checkpoint = @import("turn_checkpoint.zig");-fn surfaceUnstreamedText(self: *Agent, text: []const u8) !void {+pub fn surfaceUnstreamedText(self: *Agent, text: []const u8) !void {if (self.sub or self.streamed_text or text.len == 0) return;if (main_mod.json_mode) {self.emit(.{ .type = "text", .text = text });@@ -45,7 +45,7 @@ const sseIndex = Agent.sseIndex;/// keep stepping. Bounded by max_repair_grants — reset on any green eval in/// runEval — so a permanently-red eval still terminates; when the budget is/// spent the caller falls back to the old end-the-turn behavior.-fn grantRepairTurn(self: *Agent) !bool {+pub fn grantRepairTurn(self: *Agent) !bool {if (self.eval_repair_grants >= eval_control.max_repair_grants) return false;// A repair turn costs at least a repair call plus a concluding call.// Without that headroom in the run budget, granting one just converts@@ -54,7 +54,7 @@ fn grantRepairTurn(self: *Agent) !bool {// surface the hard stop instead, exactly the pre-grant contract.if (self.run_budget) |b| if (!b.canAfford(2)) return false;self.eval_repair_grants += 1;- try self.messages.append(try messages_mod.textMessage(self.arena, "user", eval_control.verifier_hard_stop));+ try self.messages.append(try messages_mod.userNote(self.arena, self.provider.kind, eval_control.verifier_hard_stop));return true;}@@ -313,6 +313,16 @@ pub fn stepOpenAI(self: *Agent, root: std.json.ObjectMap) !?[]const u8 {return final_text;}+/// One turn's response, handed to the step function for this wire.+pub fn stepForWire(self: *Agent, root: std.json.ObjectMap) !?[]const u8 {+ return switch (self.provider.kind) {+ .anthropic => self.stepAnthropic(root),+ .openai => self.stepOpenAI(root),+ .responses => self.stepResponses(root),+ .interactions => @import("interactions_steps.zig").step(self, root),+ };+}+/// Reassemble a streamed SSE body into the non-streaming response shape/// the step functions expect. Returns null when the body contains no SSE/// events (a plain JSON body — error envelope, or a provider that@@ -322,6 +332,7 @@ pub fn assembleStream(self: *Agent, body: []const u8) !?std.json.ObjectMap {.anthropic => self.assembleAnthropic(body),.openai => self.assembleOpenAI(body),.responses => unreachable, // parseResponses owns this path+ .interactions => @import("interactions_stream.zig").assemble(self, body),};}@@ -432,6 +443,9 @@ const CallAcc = struct {name: []const u8 = "",args: std.ArrayList(u8) = .empty,thought_signature: []const u8 = "",+ /// Google hangs the signature off the CALL (extra_content.google.thought_signature);+ /// echoing it on the message alone drops the binding, so keep it where it came from.+ extra_content: ?Value = null,};pub fn assembleOpenAI(self: *Agent, body: []const u8) !?std.json.ObjectMap {@@ -510,7 +524,10 @@ pub fn assembleOpenAI(self: *Agent, body: []const u8) !?std.json.ObjectMap {if (tc.object.get("thought_signature")) |x| if (x == .string and x.string.len > 0) {acc.thought_signature = x.string;};- if (tc.object.get("extra_content")) |ec| extra_content = extra_content orelse ec;+ if (tc.object.get("extra_content")) |ec| {+ acc.extra_content = ec;+ extra_content = extra_content orelse ec;+ }if (tc.object.get("function")) |f| if (f == .object) {if (f.object.get("name")) |x| if (x == .string and x.string.len > 0) {acc.name = x.string;@@ -526,7 +543,11 @@ pub fn assembleOpenAI(self: *Agent, body: []const u8) !?std.json.ObjectMap {try message.put(result_arena, "role", .{ .string = try result_arena.dupe(u8, role) }); // #124: role slices the scratch parse tree; dupe so it survives the per-request scratch resetif (message_id.len > 0) try message.put(result_arena, "id", .{ .string = try result_arena.dupe(u8, message_id) });if (thought_signature.len > 0) try message.put(result_arena, "thought_signature", .{ .string = try result_arena.dupe(u8, thought_signature) });- if (extra_content) |ec| try message.put(result_arena, "extra_content", ec);+ // #124: extra_content slices the per-request SCRATCH parse tree, which is+ // reset before the next request — storing it raw left the session holding+ // freed memory (sanitizeValueUtf8 then recursed through garbage until the+ // stack blew). Deep-copy it into the message arena like every other field.+ if (extra_content) |ec| try message.put(result_arena, "extra_content", try util.dupeJsonValue(result_arena, ec));try message.put(result_arena, "content", if (content.items.len > 0) Value{ .string = content.items } else .null);if (reasoning_content.items.len > 0) try message.put(result_arena, "reasoning_content", .{ .string = reasoning_content.items });if (reasoning.items.len > 0) try message.put(result_arena, "reasoning", .{ .string = reasoning.items });@@ -543,6 +564,7 @@ pub fn assembleOpenAI(self: *Agent, body: []const u8) !?std.json.ObjectMap {try tc.put(result_arena, "function", .{ .object = function });const call_sig = if (c.thought_signature.len > 0) c.thought_signature else thought_signature;if (call_sig.len > 0) try tc.put(result_arena, "thought_signature", .{ .string = try result_arena.dupe(u8, call_sig) });+ if (c.extra_content) |ec| try tc.put(result_arena, "extra_content", try util.dupeJsonValue(result_arena, ec));try tcs.append(.{ .object = tc });}if (tcs.items.len > 0) try message.put(result_arena, "tool_calls", .{ .array = tcs });@@ -559,39 +581,6 @@ pub fn assembleOpenAI(self: *Agent, body: []const u8) !?std.json.ObjectMap {return r;}-test "assembleOpenAI preserves streamed reasoning and Gemini echo fields" {- var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);- defer arena_state.deinit();- const arena = arena_state.allocator();- var agent: Agent = .{- .gpa = std.testing.allocator,- .arena = arena,- .io = undefined,- .client = undefined,- .provider = undefined,- .messages = undefined,- .sub = false,- .label = "test",- .out = null,- };-- const root = (try agent.assembleOpenAI(- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"role\":\"assistant\",\"thought_signature\":\"SIG\"}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning_content\":\"think \"}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning_content\":\"deep\"}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning\":\"alt \"}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning\":\"path\"}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"c1\",\"function\":{\"name\":\"get_weather\",\"arguments\":\"{}\"},\"thought_signature\":\"SIG\"}]}}]}\n" ++- "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"content\":\"done\"},\"finish_reason\":\"tool_calls\"}]}\n" ++- "data: [DONE]\n",- )).?;- const choices = root.get("choices").?;- const message = choices.array.items[0].object.get("message").?.object;- try std.testing.expectEqualStrings("assistant", message.get("role").?.string);- try std.testing.expectEqualStrings("done", message.get("content").?.string);- try std.testing.expectEqualStrings("think deep", message.get("reasoning_content").?.string);- try std.testing.expectEqualStrings("alt path", message.get("reasoning").?.string);- try std.testing.expectEqualStrings("v1_thread", message.get("id").?.string);- try std.testing.expectEqualStrings("SIG", message.get("thought_signature").?.string);- try std.testing.expectEqualStrings("SIG", message.get("tool_calls").?.array.items[0].object.get("thought_signature").?.string);+test {+ _ = @import("agent_steps_tests.zig");}diff --git a/src/agent_steps_tests.zig b/src/agent_steps_tests.zignew file mode 100644index 00000000..731c1c38--- /dev/null+++ b/src/agent_steps_tests.zig@@ -0,0 +1,55 @@+//! White-box tests for agent_steps.zig's stream assembler, parked here under+//! the 600-line ceiling (same pattern as router_catalog_tests.zig).++const std = @import("std");+const Agent = @import("agent.zig").Agent;++test "assembleOpenAI preserves streamed reasoning and Gemini echo fields" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ var agent: Agent = .{+ .gpa = std.testing.allocator,+ .arena = arena,+ .io = undefined,+ .client = undefined,+ .provider = undefined,+ .messages = undefined,+ .sub = false,+ .label = "test",+ .out = null,+ };++ const root = (try agent.assembleOpenAI(+ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"role\":\"assistant\",\"thought_signature\":\"SIG\"}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning_content\":\"think \"}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning_content\":\"deep\"}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning\":\"alt \"}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"reasoning\":\"path\"}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"c1\",\"function\":{\"name\":\"get_weather\",\"arguments\":\"{}\"},\"thought_signature\":\"SIG\"}]}}]}\n" +++ "data: {\"id\":\"v1_thread\",\"choices\":[{\"delta\":{\"content\":\"done\"},\"finish_reason\":\"tool_calls\"}]}\n" +++ "data: [DONE]\n",+ )).?;+ const choices = root.get("choices").?;+ const message = choices.array.items[0].object.get("message").?.object;+ try std.testing.expectEqualStrings("assistant", message.get("role").?.string);+ try std.testing.expectEqualStrings("done", message.get("content").?.string);+ try std.testing.expectEqualStrings("think deep", message.get("reasoning_content").?.string);+ try std.testing.expectEqualStrings("alt path", message.get("reasoning").?.string);+ try std.testing.expectEqualStrings("v1_thread", message.get("id").?.string);+ try std.testing.expectEqualStrings("SIG", message.get("thought_signature").?.string);+ try std.testing.expectEqualStrings("SIG", message.get("tool_calls").?.array.items[0].object.get("thought_signature").?.string);++ // Google's own OpenAI-compat wire (as opposed to the gateway's flattened+ // one): the signature rides extra_content on the CALL, and the turn ends+ // "stop" even though it is a tool call. Both must survive the echo, or the+ // next request loses the thinking binding for that call.+ const google = (try agent.assembleOpenAI(+ "data: {\"choices\":[{\"delta\":{\"role\":\"assistant\",\"tool_calls\":[{\"index\":0,\"id\":\"c9\",\"function\":{\"name\":\"bash\",\"arguments\":\"{}\"},\"extra_content\":{\"google\":{\"thought_signature\":\"GSIG\"}}}]},\"finish_reason\":\"stop\"}]}\n" +++ "data: [DONE]\n",+ )).?;+ const gchoice = google.get("choices").?.array.items[0].object;+ const gcall = gchoice.get("message").?.object.get("tool_calls").?.array.items[0].object;+ try std.testing.expectEqualStrings("stop", gchoice.get("finish_reason").?.string);+ try std.testing.expectEqualStrings("GSIG", gcall.get("extra_content").?.object.get("google").?.object.get("thought_signature").?.string);+}diff --git a/src/agent_stream.zig b/src/agent_stream.zigindex 2cdafecc..60398db6 100644--- a/src/agent_stream.zig+++ b/src/agent_stream.zig@@ -78,7 +78,9 @@ pub fn postStreamWithClient(self: *Agent, client: *std.http.Client, body: []consconst gpa = self.gpa;const provider = self.provider;const bearer = switch (provider.auth) {- .x_api_key => "",+ // Key-header styles carry the key in their own header (see+ // providerHeadersWithConv); only bearer needs the scheme prefix.+ .x_api_key, .goog_api_key => "",.bearer => try std.fmt.allocPrint(gpa, "Bearer {s}", .{provider.api_key}),};defer if (bearer.len > 0) gpa.free(bearer);@@ -367,7 +369,9 @@ pub fn isStreamEnd(arena: std.mem.Allocator, kind: anytype, raw_line: []const u8// xAI/OpenAI Responses: `event: response.completed` is the SSE name;// usage rides the following `data:` line. Ending here made -p// `[usage]` print 0 calls (live stream never saw the payload).- .responses, .openai => false,+ // Interactions ends with `event: done` + `data: [DONE]`, caught above;+ // `interaction.completed` carries the usage that must still be read.+ .responses, .openai, .interactions => false,};const payload = ssePayload(raw_line) orelse return false;const candidate = switch (kind) {@@ -375,7 +379,7 @@ pub fn isStreamEnd(arena: std.mem.Allocator, kind: anytype, raw_line: []const u8.responses => std.mem.indexOf(u8, payload, "response.completed") != null orstd.mem.indexOf(u8, payload, "response.incomplete") != null orstd.mem.indexOf(u8, payload, "response.failed") != null,- .openai => false,+ .openai, .interactions => false,};if (!candidate) return false;const v = std.json.parseFromSliceLeaky(Value, arena, payload, .{ .allocate = .alloc_always }) catch return false;@@ -387,7 +391,7 @@ pub fn isStreamEnd(arena: std.mem.Allocator, kind: anytype, raw_line: []const u8.responses => std.mem.eql(u8, ty.string, "response.completed") orstd.mem.eql(u8, ty.string, "response.incomplete") orstd.mem.eql(u8, ty.string, "response.failed"),- .openai => false,+ .openai, .interactions => false,};}@@ -440,6 +444,16 @@ pub fn printDelta(self: *Agent, raw_line: []const u8) void {if (modelOutputStarted(self.provider.kind, obj)) self.traceFirstToken();self.argLiveDelta(obj);const text: []const u8 = switch (self.provider.kind) {+ // step.delta with a "text" delta is the only prose on this wire; a+ // thought_signature delta carries an opaque blob, never display text.+ .interactions => blk: {+ const d = obj.get("delta") orelse break :blk "";+ if (d != .object) break :blk "";+ const dt = d.object.get("type") orelse break :blk "";+ if (dt != .string or !std.mem.eql(u8, dt.string, "text")) break :blk "";+ const x = d.object.get("text") orelse break :blk "";+ break :blk if (x == .string) x.string else "";+ },.anthropic => blk: {const t = obj.get("type") orelse break :blk "";if (t != .string or !std.mem.eql(u8, t.string, "content_block_delta")) break :blk "";@@ -496,6 +510,13 @@ pub fn printDelta(self: *Agent, raw_line: []const u8) void {/// or function-call bytes across the three streaming wires.fn modelOutputStarted(kind: @import("provider.zig").Provider.Kind, obj: std.json.ObjectMap) bool {return switch (kind) {+ // The first step.start/step.delta is the first model-authored byte,+ // thought steps included (they are what the model is doing first).+ .interactions => blk: {+ const t = obj.get("event_type") orelse break :blk false;+ if (t != .string) break :blk false;+ break :blk std.mem.eql(u8, t.string, "step.start") or std.mem.eql(u8, t.string, "step.delta");+ },.anthropic => blk: {const t = obj.get("type") orelse break :blk false;if (t != .string) break :blk false;diff --git a/src/http.zig b/src/http.zigindex 86020f44..84568f57 100644--- a/src/http.zig+++ b/src/http.zig@@ -122,7 +122,8 @@ fn post(gpa: Allocator, client: *std.http.Client, provider: Provider, body: []coerrdefer aw.deinit();const bearer = switch (provider.auth) {- .x_api_key => "",+ // Key-header styles carry the key in their own header; only bearer prefixes.+ .x_api_key, .goog_api_key => "",.bearer => try std.fmt.allocPrint(gpa, "Bearer {s}", .{provider.api_key}),};defer if (bearer.len > 0) gpa.free(bearer);diff --git a/src/http_headers.zig b/src/http_headers.zigindex 190a3ee1..7a3ffb05 100644--- a/src/http_headers.zig+++ b/src/http_headers.zig@@ -79,6 +79,18 @@ pub fn requestCacheKey(io: Io, label: []const u8, agent: *const anyopaque, provireturn promptCacheKey(io, label, agent, buf);}+/// Write the body's `prompt_cache_key`, unless this provider rejects it.+/// Google validates the payload strictly and fails the WHOLE request on an+/// unknown field ("Unknown name \"prompt_cache_key\": Cannot find field."),+/// and it caches implicitly, so it is the one openai-wire provider that+/// carries no partition key. Everything else must still pin one.+pub fn writeRequestCacheKey(s: anytype, io: Io, label: []const u8, agent: *const anyopaque, provider_id: []const u8) !void {+ if (std.mem.eql(u8, provider_id, "google")) return;+ var buf: [96]u8 = undefined;+ try s.objectField("prompt_cache_key");+ try s.write(requestCacheKey(io, label, agent, provider_id, &buf));+}+var project_id_buf: [36]u8 = undefined;var project_id_len: usize = 0;var project_id_lock: std.atomic.Value(bool) = .init(false);@@ -186,6 +198,12 @@ pub fn providerHeadersWithConv(io: Io, provider: Provider, bearer: []const u8, bbuf[count] = .{ .name = "authorization", .value = bearer };count += 1;},+ // generativelanguage rejects an API key sent as `Authorization: Bearer`+ // with a 401 asking for an OAuth token — it wants its own header.+ .goog_api_key => {+ buf[count] = .{ .name = "x-goog-api-key", .value = provider.api_key };+ count += 1;+ },}// SuperGrok user tokens need the grok-build routing header.if (std.mem.eql(u8, provider.id, "xai") and provider.source == .login) {diff --git a/src/interactions_steps.zig b/src/interactions_steps.zignew file mode 100644index 00000000..d9ea0196--- /dev/null+++ b/src/interactions_steps.zig@@ -0,0 +1,185 @@+//! Building and reading Google Interactions execution steps — the unit of+//! history on that wire, where the other three wires have messages or items.+//!+//! graff stores these verbatim in `Agent.messages`, so a step written here is+//! echoed back to the endpoint on the next turn exactly as it is built.++const std = @import("std");+const Value = std.json.Value;+const Allocator = std.mem.Allocator;++/// `{"type":"user_input","content":"…"}`. The endpoint also accepts a content+/// ARRAY of parts (vision.zig builds that form); a plain string is the shape+/// for text-only input.+pub fn userInput(arena: Allocator, text: []const u8) !Value {+ var obj: std.json.ObjectMap = .empty;+ try obj.put(arena, "type", .{ .string = "user_input" });+ try obj.put(arena, "content", .{ .string = try arena.dupe(u8, text) });+ return .{ .object = obj };+}++/// `{"type":"function_result","call_id":…,"name":…,"result":[{"type":"text",…}]}`.+/// All three fields are required: without `name` the endpoint answers a bare+/// "Invalid input received.", and `result` must be a LIST of parts, not a+/// string and not an object.+pub fn functionResult(arena: Allocator, call_id: []const u8, name: []const u8, text: []const u8) !Value {+ var part: std.json.ObjectMap = .empty;+ try part.put(arena, "type", .{ .string = "text" });+ try part.put(arena, "text", .{ .string = try arena.dupe(u8, text) });+ var result = std.json.Array.init(arena);+ try result.append(.{ .object = part });+ var obj: std.json.ObjectMap = .empty;+ try obj.put(arena, "type", .{ .string = "function_result" });+ try obj.put(arena, "call_id", .{ .string = try arena.dupe(u8, call_id) });+ try obj.put(arena, "name", .{ .string = try arena.dupe(u8, name) });+ try obj.put(arena, "result", .{ .array = result });+ return .{ .object = obj };+}++fn stepType(s: Value) []const u8 {+ if (s != .object) return "";+ const t = s.object.get("type") orelse return "";+ return if (t == .string) t.string else "";+}++/// The assistant's visible answer: the text parts of every model_output step.+/// A thought step carries only an opaque signature and contributes nothing.+pub fn assistantText(arena: Allocator, root: std.json.ObjectMap) ![]const u8 {+ const steps = root.get("steps") orelse return "";+ if (steps != .array) return "";+ var out: std.ArrayList(u8) = .empty;+ for (steps.array.items) |s| {+ if (!std.mem.eql(u8, stepType(s), "model_output")) continue;+ const content = s.object.get("content") orelse continue;+ if (content != .array) continue;+ for (content.array.items) |part| {+ if (part != .object) continue;+ if (part.object.get("text")) |t| if (t == .string) try out.appendSlice(arena, t.string);+ }+ }+ return out.items;+}++/// Record one Interaction's usage. Interactions reports flat totals under its+/// own names; thinking is billed as output and is most of a Gemini turn's+/// output, so a tally that skipped it would understate every call.+/// `total_cached_tokens` is the cached PORTION of the input, matching how the+/// other wires report a cache read.+pub fn recordUsage(self: *@import("agent.zig").Agent, u: std.json.ObjectMap, fallback: u64) void {+ const ctx = @import("agent_context.zig");+ const in_tokens = ctx.usageInt(u, "total_input_tokens");+ const out_tokens = ctx.usageInt(u, "total_output_tokens") +| ctx.usageInt(u, "total_thought_tokens");+ const total = @max(ctx.usageInt(u, "total_tokens"), in_tokens +| out_tokens);+ if (total > 0) ctx.replaceContextTokens(self, @intCast(total)) else ctx.floorContextTokens(self, fallback);+ self.last_usage_includes_output = total > 0;+ const cached = ctx.usageInt(u, "total_cached_tokens");+ if (cached > 0) self.last_cache_read = @intCast(cached);+ self.recordCost(@max(in_tokens - cached, 0), cached, 0, out_tokens);+}++/// A function_result rebuilt out of band (vision/repl replay), where only the+/// call id is known. Interactions requires `name` and rejects the request+/// without it; the live turn path uses `functionResult` with the real name.+pub fn fallbackResult(arena: Allocator, call_id: []const u8, text: []const u8, is_error: bool) !Value {+ const body = if (is_error) try std.fmt.allocPrint(arena, "[error] {s}", .{text}) else text;+ return functionResult(arena, call_id, "tool", body);+}++/// One image as an Interactions content part: raw base64 plus its mime type.+/// `source` / `image_url` / `inline_data` are all rejected as unknown+/// parameters, and a remote URL has no proven inline form on this wire, so it+/// rides as text rather than being silently dropped.+pub fn imagePart(arena: Allocator, ib: *std.json.ObjectMap, img: anytype) !void {+ if (img.b64.len > 0) {+ try ib.put(arena, "type", .{ .string = "image" });+ try ib.put(arena, "data", .{ .string = img.b64 });+ try ib.put(arena, "mime_type", .{ .string = img.media_type });+ } else {+ try ib.put(arena, "type", .{ .string = "text" });+ try ib.put(arena, "text", .{ .string = try std.fmt.allocPrint(arena, "[image: {s}]", .{img.url}) });+ }+}++/// One turn on the Interactions wire: echo the model's steps into history,+/// dispatch any function_call steps, and answer with the visible text once the+/// model stops calling tools. Mirrors stepOpenAI / stepResponses.+pub fn step(self: *@import("agent.zig").Agent, root: std.json.ObjectMap) !?[]const u8 {+ const agent_steps = @import("agent_steps.zig");+ const steps = root.get("steps") orelse {+ try self.sayApiError("api error: interaction had no steps", .{});+ return error.ApiError;+ };+ if (steps != .array) {+ try self.sayApiError("api error: interaction steps were not a list", .{});+ return error.ApiError;+ }+ // Echo every step back verbatim next turn — the thought signature is opaque+ // and the endpoint validates it, so it must survive unedited.+ for (steps.array.items) |st| try self.messages.append(st);++ const final_text = try assistantText(self.arena, root);+ if (final_text.len > 0) try agent_steps.surfaceUnstreamedText(self, final_text);++ var calls: std.ArrayList(agent_steps.ToolCall) = .empty;+ defer calls.deinit(self.gpa);+ for (steps.array.items) |st| {+ if (!std.mem.eql(u8, stepType(st), "function_call")) continue;+ const name = if (st.object.get("name")) |n| (if (n == .string) n.string else "") else "";+ if (name.len == 0) continue; // can't dispatch a nameless call+ const id = if (st.object.get("id")) |x| (if (x == .string) x.string else "") else "";+ // Unlike every other wire, `arguments` is already a JSON object here —+ // there is no argument string to parse.+ const input: Value = if (st.object.get("arguments")) |a| (if (a == .object) a else .{ .object = .empty }) else .{ .object = .empty };+ try calls.append(self.gpa, .{ .id = id, .name = name, .input = input });+ }+ self.pairContextMeterWithCurrentLocal();++ if (calls.items.len > 0) {+ const results = try self.runTools(calls.items);+ for (calls.items, results) |call, r| {+ try self.messages.append(try functionResult(self.arena, call.id, call.name, r.text));+ }+ try @import("turn_checkpoint.zig").afterToolBatch(self);+ const eval_control = @import("agent_eval_control.zig");+ if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) {+ if (try agent_steps.grantRepairTurn(self)) return null;+ return eval_control.verifier_hard_stop;+ }+ if (self.completed) |result| return result;+ return null;+ }+ return final_text;+}++test "userInput and functionResult build the shapes the endpoint requires" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();++ const u = try userInput(arena, "hello");+ try std.testing.expectEqualStrings("user_input", u.object.get("type").?.string);+ try std.testing.expectEqualStrings("hello", u.object.get("content").?.string);++ const r = try functionResult(arena, "call_1", "bash", "out");+ try std.testing.expectEqualStrings("function_result", r.object.get("type").?.string);+ try std.testing.expectEqualStrings("call_1", r.object.get("call_id").?.string);+ // `name` is required: the endpoint rejects a result without it.+ try std.testing.expectEqualStrings("bash", r.object.get("name").?.string);+ // `result` is a LIST of parts, never a bare string or an object.+ const list = r.object.get("result").?;+ try std.testing.expect(list == .array);+ try std.testing.expectEqualStrings("text", list.array.items[0].object.get("type").?.string);+ try std.testing.expectEqualStrings("out", list.array.items[0].object.get("text").?.string);+}++test "assistantText concatenates model_output text and ignores thoughts" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ const parsed = try std.json.parseFromSlice(Value, arena,+ \\{"steps":[{"type":"thought","signature":"OPAQUE"},+ \\ {"type":"model_output","content":[{"type":"text","text":"one "},{"type":"text","text":"two"}]}]}+ , .{});+ defer parsed.deinit();+ try std.testing.expectEqualStrings("one two", try assistantText(arena, parsed.value.object));+}diff --git a/src/interactions_stream.zig b/src/interactions_stream.zignew file mode 100644index 00000000..843f1e77--- /dev/null+++ b/src/interactions_stream.zig@@ -0,0 +1,126 @@+//! Reassemble Google's Interactions SSE into the non-streaming Interaction+//! shape the step functions read, mirroring what assembleOpenAI/assembleAnthropic+//! do for their wires.+//!+//! The event vocabulary (named SSE events, `data:` payload also carries+//! `event_type`):+//!+//! interaction.created {"interaction":{"id","status","model"}}+//! step.start {"index":0,"step":{"type":"thought"}}+//! step.delta {"index":0,"delta":{"type":"thought_signature","signature":"…"}}+//! {"index":1,"delta":{"type":"text","text":"…"}}+//! {"index":1,"delta":{"type":"arguments_delta","arguments":"{\"a\":1}"}}+//! step.stop {"index":1}+//! interaction.completed {"interaction":{"status":"completed"|"requires_action","usage":{…}}}+//! done [DONE]+//!+//! `arguments` arrives as chunks of a JSON *string* but must be echoed back as+//! a JSON *object*, so it is accumulated and parsed once at the end.++const std = @import("std");+const Value = std.json.Value;++const Agent = @import("agent.zig").Agent;++/// One in-flight step. `text` and `args` accumulate across deltas.+const StepAcc = struct {+ kind: []const u8 = "",+ id: []const u8 = "",+ name: []const u8 = "",+ signature: []const u8 = "",+ text: std.ArrayList(u8) = .empty,+ args: std.ArrayList(u8) = .empty,+};++fn ssePayload(line: []const u8) ?[]const u8 {+ if (!std.mem.startsWith(u8, line, "data:")) return null;+ return std.mem.trim(u8, line["data:".len..], " \t\r");+}++fn str(obj: std.json.ObjectMap, key: []const u8) []const u8 {+ const v = obj.get(key) orelse return "";+ return if (v == .string) v.string else "";+}++pub fn assemble(self: *Agent, body: []const u8) !?std.json.ObjectMap {+ const arena = self.messageMutationAlloc();+ var steps: std.ArrayList(StepAcc) = .empty;+ var usage: ?Value = null;+ var status: []const u8 = "";+ var interaction_id: []const u8 = "";+ var saw_event = false;++ var it = std.mem.tokenizeScalar(u8, body, '\n');+ while (it.next()) |raw_line| {+ const payload = ssePayload(raw_line) orelse continue;+ if (std.mem.eql(u8, payload, "[DONE]")) {+ saw_event = true;+ continue;+ }+ // #124: the per-event parse tree is transient — every string kept below+ // is duped into `arena` before the scratch allocator is reset.+ const v = std.json.parseFromSliceLeaky(Value, self.scratchAlloc(), payload, .{ .allocate = .alloc_always }) catch continue;+ if (v != .object) continue;+ saw_event = true;++ if (v.object.get("interaction")) |ix| if (ix == .object) {+ if (str(ix.object, "id").len > 0) interaction_id = try arena.dupe(u8, str(ix.object, "id"));+ if (str(ix.object, "status").len > 0) status = try arena.dupe(u8, str(ix.object, "status"));+ if (ix.object.get("usage")) |u| usage = try @import("util.zig").dupeJsonValue(arena, u);+ };++ const idx: usize = blk: {+ const i = v.object.get("index") orelse break :blk std.math.maxInt(usize);+ break :blk if (i == .integer and i.integer >= 0) @intCast(i.integer) else std.math.maxInt(usize);+ };+ if (idx == std.math.maxInt(usize)) continue;+ while (steps.items.len <= idx) try steps.append(arena, .{});+ const acc = &steps.items[idx];++ if (v.object.get("step")) |st| if (st == .object) {+ if (str(st.object, "type").len > 0) acc.kind = try arena.dupe(u8, str(st.object, "type"));+ if (str(st.object, "id").len > 0) acc.id = try arena.dupe(u8, str(st.object, "id"));+ if (str(st.object, "name").len > 0) acc.name = try arena.dupe(u8, str(st.object, "name"));+ };+ if (v.object.get("delta")) |d| if (d == .object) {+ if (str(d.object, "text").len > 0) try acc.text.appendSlice(arena, str(d.object, "text"));+ if (str(d.object, "signature").len > 0) acc.signature = try arena.dupe(u8, str(d.object, "signature"));+ if (str(d.object, "arguments").len > 0) try acc.args.appendSlice(arena, str(d.object, "arguments"));+ };+ }+ if (!saw_event) return null;++ var out_steps = std.json.Array.init(arena);+ for (steps.items) |st| {+ if (st.kind.len == 0) continue;+ var obj: std.json.ObjectMap = .empty;+ try obj.put(arena, "type", .{ .string = st.kind });+ if (std.mem.eql(u8, st.kind, "thought")) {+ if (st.signature.len > 0) try obj.put(arena, "signature", .{ .string = st.signature });+ } else if (std.mem.eql(u8, st.kind, "model_output")) {+ var part: std.json.ObjectMap = .empty;+ try part.put(arena, "type", .{ .string = "text" });+ try part.put(arena, "text", .{ .string = st.text.items });+ var content = std.json.Array.init(arena);+ try content.append(.{ .object = part });+ try obj.put(arena, "content", .{ .array = content });+ } else if (std.mem.eql(u8, st.kind, "function_call")) {+ if (st.id.len > 0) try obj.put(arena, "id", .{ .string = st.id });+ if (st.name.len > 0) try obj.put(arena, "name", .{ .string = st.name });+ // Chunks spell a JSON string; the wire wants the object back.+ const parsed: Value = if (st.args.items.len == 0)+ .{ .object = .empty }+ else+ std.json.parseFromSliceLeaky(Value, arena, st.args.items, .{ .allocate = .alloc_always }) catch .{ .object = .empty };+ try obj.put(arena, "arguments", if (parsed == .object) parsed else .{ .object = .empty });+ }+ try out_steps.append(.{ .object = obj });+ }++ var root: std.json.ObjectMap = .empty;+ try root.put(arena, "steps", .{ .array = out_steps });+ if (status.len > 0) try root.put(arena, "status", .{ .string = status });+ if (interaction_id.len > 0) try root.put(arena, "id", .{ .string = interaction_id });+ if (usage) |u| try root.put(arena, "usage", u);+ return root;+}diff --git a/src/interactions_wire.zig b/src/interactions_wire.zignew file mode 100644index 00000000..99a58c70--- /dev/null+++ b/src/interactions_wire.zig@@ -0,0 +1,77 @@+//! Google's Interactions API request body — the wire Gemini launches on.+//!+//! One POST creates one Interaction. Unlike chat messages or Responses items,+//! its history is an ordered list of execution STEPS:+//!+//! {"type":"user_input","content":"…"}+//! {"type":"thought","signature":"…"} (opaque; echo it back verbatim)+//! {"type":"model_output","content":[{"type":"text","text":"…"}]}+//! {"type":"function_call","id":"call_1","name":"bash","arguments":{…}}+//! {"type":"function_result","call_id":"call_1","name":"bash",+//! "result":[{"type":"text","text":"…"}]}+//!+//! Two shapes the endpoint enforces and every other wire does not:+//! - `arguments` is a JSON OBJECT, not a string of JSON.+//! - unknown fields fail the WHOLE request ("Unknown parameter 'strict' at+//! 'tools[0]'"), so nothing generic may be sprayed into this body.+//!+//! `store:false` keeps graff's own history authoritative, matching what the+//! Responses wire already does; server-side state via previous_interaction_id+//! is deliberately not used yet (it would need the id to survive compaction).++const std = @import("std");++const Agent = @import("agent.zig").Agent;+const serde = @import("serde.zig");++/// graff's effort tag → Interactions `thinking_level`. The endpoint names its+/// own accepted set in the rejection: high, low, medium, minimal, none.+pub fn thinkingLevel(effort: []const u8) []const u8 {+ if (std.mem.eql(u8, effort, "max") or std.mem.eql(u8, effort, "high")) return "high";+ if (std.mem.eql(u8, effort, "medium")) return "medium";+ if (std.mem.eql(u8, effort, "minimal") or std.mem.eql(u8, effort, "none")) return "minimal";+ return "low";+}++pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_tool: bool, stream: bool) !void {+ try s.objectField("system_instruction");+ try s.write(try @import("agent_request_body_responses.zig").schemaAwarePrompt(self));+ // graff replays the full step list every turn, so the server keeps nothing.+ try s.objectField("store");+ try s.write(false);+ try s.objectField("generation_config");+ try s.beginObject();+ try s.objectField("thinking_level");+ try s.write(thinkingLevel(@tagName(self.reasoning)));+ // tool_choice lives HERE, not at the top level, and its enum is lowercase:+ // auto | any | none. "required"/"ANY" are both rejected outright.+ if (tools != null) {+ try s.objectField("tool_choice");+ try s.write(if (force_tool) "any" else "auto");+ }+ try s.endObject();+ if (tools) |t| {+ try s.objectField("tools");+ try serde.writeOpenAITools(s, self.scratchAlloc(), t);+ }+ try s.objectField("input");+ try s.beginArray();+ for (self.messages.items) |m| try s.write(m);+ try s.endArray();+ if (stream) {+ try s.objectField("stream");+ try s.write(true);+ }+}++test "thinking_level maps graff's efforts onto the accepted set" {+ // The set is the endpoint's own: "Valid values are: high, low, medium,+ // minimal, none" — anything else 400s the request.+ try std.testing.expectEqualStrings("high", thinkingLevel("max"));+ try std.testing.expectEqualStrings("high", thinkingLevel("high"));+ try std.testing.expectEqualStrings("medium", thinkingLevel("medium"));+ try std.testing.expectEqualStrings("low", thinkingLevel("low"));+ try std.testing.expectEqualStrings("minimal", thinkingLevel("minimal"));+ // An unknown tag degrades to a level the endpoint accepts, never to a 400.+ try std.testing.expectEqualStrings("low", thinkingLevel("nonsense"));+}diff --git a/src/messages.zig b/src/messages.zigindex 89cbd95b..c3a34806 100644--- a/src/messages.zig+++ b/src/messages.zig@@ -71,12 +71,22 @@ fn userPromptText(msg: Value) ?[]const u8 {/// `function_call_output` item. Error reporting differs per wire format:/// anthropic carries a separate `is_error` flag, openai inlines an `[error]`/// prefix, and responses has no error channel (text only).+/// A harness-authored note injected into history as if the user said it+/// (budget landing, repair grant, empty-completion bounce, compaction handoff).+/// Interactions rejects a bare `{"role":"user"}` — every entry on that wire is+/// a typed step — so the shape has to follow the wire, not the caller.+pub fn userNote(arena: Allocator, kind: Provider.Kind, text: []const u8) !Value {+ if (kind == .interactions) return @import("interactions_steps.zig").userInput(arena, text);+ return textMessage(arena, "user", text);+}+pub fn toolResultMessage(arena: Allocator, kind: Provider.Kind, call_id: []const u8, raw_text: []const u8, is_error: bool) !Value {// Scrub raw bytes (binary tool output etc.) at the source so the result is a// valid JSON string, not a byte-integer array the API rejects.const text = sanitizeUtf8(arena, raw_text);var obj: std.json.ObjectMap = .empty;switch (kind) {+ .interactions => return @import("interactions_steps.zig").fallbackResult(arena, call_id, text, is_error),.anthropic => {try obj.put(arena, "type", .{ .string = "tool_result" });try obj.put(arena, "tool_use_id", .{ .string = call_id });diff --git a/src/named_work.zig b/src/named_work.zigindex 78854f08..f546aada 100644--- a/src/named_work.zig+++ b/src/named_work.zig@@ -132,6 +132,7 @@ pub fn responsesUserMessage(arena: std.mem.Allocator, text: []const u8) !Value {pub fn userNudge(arena: std.mem.Allocator, kind: @import("provider.zig").Provider.Kind, text: []const u8) !Value {return switch (kind) {.responses => responsesUserMessage(arena, text),+ .interactions => @import("interactions_steps.zig").userInput(arena, text),.openai, .anthropic => messages_mod.textMessage(arena, "user", text),};}diff --git a/src/pricing.zig b/src/pricing.zigindex af22766d..d9ee6e99 100644--- a/src/pricing.zig+++ b/src/pricing.zig@@ -296,6 +296,22 @@ pub const model_table = [_]ModelInfo{.{ .provider = "zai", .name = "glm-5", .context = 204_800 },.{ .provider = "zai", .name = "glm-4.7", .context = 204_800 },.{ .provider = "zai", .name = "glm-4.5", .context = 131_072 },+ // Google AI Studio. Every gemini-3.x row is the live inputTokenLimit+ // (1,048,576) read from generativelanguage /v1beta/models — its+ // OpenAI-compat /models omits the window entirely, so without these rows+ // contextFor falls to default_context and a 1M model compacts at 160k.+ // Efforts mirror the compat layer's own rejection message: "Valid values+ // are: high, low, medium, minimal, none".+ .{ .provider = "google", .name = "gemini-3.8-flash", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both, .support_efforts = &.{ "minimal", "low", "medium", "high" }, .default_effort = "medium" },+ .{ .provider = "google", .name = "gemini-3.7-flash", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both, .support_efforts = &.{ "minimal", "low", "medium", "high" }, .default_effort = "medium" },+ .{ .provider = "google", .name = "gemini-3.6-flash", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemini-3.5-flash", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemini-3.5-flash-lite", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemini-3.1-pro-preview", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemini-3.1-flash-lite", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemini-3-flash-preview", .context = 1_048_576, .supports_reasoning = true, .thinking_support = .both },+ .{ .provider = "google", .name = "gemma-4-31b-it", .context = 262_144 },+ .{ .provider = "google", .name = "gemma-4-26b-a4b-it", .context = 262_144 },.{ .provider = "vercel", .name = "alibaba/qwen3.8-27b", .context = 1_000_000, .supports_reasoning = true },.{ .provider = "openrouter", .name = "anthropic/claude-sonnet-4.6", .context = 1_000_000, .supports_reasoning = true },};diff --git a/src/provider.zig b/src/provider.zigindex c72630d4..0ec18b86 100644--- a/src/provider.zig+++ b/src/provider.zig@@ -87,6 +87,12 @@ pub const provider_specs = [_]ProviderSpec{.{ .id = "codegraff", .display_name = "Codegraff", .kind = .openai, .auth = .bearer, .url = "https://gateway.codegraff.com/v1/chat/completions", .env_key = "CODEGRAFF_API_KEY", .default_model = "deepseek-v4-pro", .login = .codegraff_device, .catalog = .openai, .models_url = "https://gateway.codegraff.com/v1/models", .takes_effort = true },.{ .id = "deepseek", .display_name = "DeepSeek", .kind = .openai, .auth = .bearer, .url = "https://api.deepseek.com/chat/completions", .env_key = "DEEPSEEK_API_KEY", .default_model = "deepseek-v4-pro", .takes_effort = true },.{ .id = "openai", .display_name = "OpenAI", .kind = .responses, .auth = .bearer, .url = "https://api.openai.com/v1/responses", .env_key = "OPENAI_API_KEY", .default_model = "gpt-5.6" },+ // Google AI Studio on its first-party Interactions API — the wire Google+ // says every new model and agent capability launches on, not the+ // OpenAI-compatibility shim. A turn POSTs one Interaction and reads back+ // execution steps; `store:false` keeps graff's own history authoritative,+ // matching what it already does on the Responses wire.+ .{ .id = "google", .display_name = "Google Gemini", .kind = .interactions, .auth = .goog_api_key, .url = "https://generativelanguage.googleapis.com/v1beta/interactions", .env_key = "GEMINI_API_KEY", .default_model = "gemini-3.8-flash", .catalog = .openai, .models_url = "https://generativelanguage.googleapis.com/v1beta/models?pageSize=200", .takes_effort = true },.{ .id = "minimax", .display_name = "MiniMax", .kind = .anthropic, .auth = .bearer, .url = "https://api.minimax.io/anthropic/v1/messages", .env_key = "MINIMAX_API_KEY", .default_model = "MiniMax-M3" },.{ .id = "xiaomi", .display_name = "Xiaomi", .kind = .openai, .auth = .bearer, .url = "https://api.xiaomimimo.com/v1/chat/completions", .env_key = "XIAOMI_API_KEY", .default_model = "mimo-v2.5-pro" },.{ .id = "kilo", .display_name = "Kilo Gateway", .kind = .openai, .auth = .bearer, .url = "https://api.kilo.ai/api/gateway/v1/chat/completions", .env_key = "KILO_API_KEY", .default_model = "kilo-auto/small" },@@ -186,8 +192,15 @@ pub const Provider = struct {// Wire format. `responses` is the first-party OpenAI Responses API (direct// API key or ChatGPT/Codex login) — input items, not chat messages.- pub const Kind = enum { anthropic, openai, responses };- pub const Auth = enum { x_api_key, bearer };+ // `interactions` is Google's first-party Interactions API: one Interaction+ // per turn, carrying an ordered list of execution STEPS (thought /+ // model_output / function_call / function_result) rather than chat messages+ // or Responses items. Its own SSE vocabulary is step.start/delta/stop.+ pub const Kind = enum { anthropic, openai, responses, interactions };+ // `goog_api_key` is Google's `x-goog-api-key` header. It is not+ // interchangeable with bearer: generativelanguage rejects an API key sent+ // as `Authorization: Bearer` with a 401 asking for an OAuth token.+ pub const Auth = enum { x_api_key, bearer, goog_api_key };/// Auto-compact past a percentage (default 80%) of the model's context window./// GRAFF_COMPACT_PCT overrides the percentage, clamped to 1..100 (#204). Unlikediff --git a/src/provider_tests.zig b/src/provider_tests.zigindex 5d8d4886..5b0c9fc3 100644--- a/src/provider_tests.zig+++ b/src/provider_tests.zig@@ -64,6 +64,29 @@ test "compactAt (#204): GRAFF_COMPACT_PCT overrides the 80% default, both directtry std.testing.expectEqual(@as(u64, 95_000), p.compactAt());}+test "gemini routes to google, not the gateway, and carries the real 1M window" {+ const all = Keys{ .values = @splat("k") };+ // Before the google row existed, gemini-* was uncatalogued: providerFor fell+ // through to the codegraff gateway and contextFor returned default_context,+ // so a 1,048,576-token model auto-compacted at 160k instead of 838k.+ const gemini = try all.providerFor("gemini-3.8-flash");+ try std.testing.expectEqualStrings("google", gemini.id);+ try std.testing.expectEqual(@as(u64, 1_048_576), gemini.context);+ try std.testing.expect(gemini.compactAt() > 800_000);+ // Gemini talks Google's first-party Interactions wire, not the OpenAI+ // compatibility shim, and authenticates with x-goog-api-key.+ try std.testing.expectEqual(Provider.Kind.interactions, gemini.kind);+ try std.testing.expectEqual(Provider.Auth.goog_api_key, gemini.auth);++ // With no GEMINI_API_KEY the model is catalogued but unkeyed, which #294+ // says must fail loudly rather than silently bill the gateway.+ var keyless = Keys{ .values = @splat(null) };+ for (provider_specs, 0..) |spec, i| {+ if (!std.mem.eql(u8, spec.id, "google")) keyless.values[i] = "k";+ }+ try std.testing.expectError(error.MissingKey, keyless.providerFor("gemini-3.8-flash"));+}+test "Keys.build: GRAFF_VERCEL_URL rewires only the Vercel endpoint" {const all = Keys{ .values = @splat("k") };provider_mod.g_vercel_url_override = provider_mod.vercel_v1_url;diff --git a/src/rlm_query.zig b/src/rlm_query.zigindex 0ecde4c8..ef5140da 100644--- a/src/rlm_query.zig+++ b/src/rlm_query.zig@@ -73,6 +73,19 @@ pub fn buildBody(gpa: Allocator, provider: Provider, prompt: []const u8) ![]u8 {try s.objectField("input");try s.write(prompt);},+ // Interactions takes a bare string as `input` like Responses, but caps+ // output under generation_config and keeps nothing when store is false.+ .interactions => {+ try s.objectField("store");+ try s.write(false);+ try s.objectField("generation_config");+ try s.beginObject();+ try s.objectField("max_output_tokens");+ try s.write(max_out_tokens);+ try s.endObject();+ try s.objectField("input");+ try s.write(prompt);+ },.anthropic => {try s.objectField("max_tokens");try s.write(max_out_tokens);diff --git a/src/router_catalog.zig b/src/router_catalog.zigindex 8ee96e0a..f356246d 100644--- a/src/router_catalog.zig+++ b/src/router_catalog.zig@@ -169,7 +169,9 @@ pub fn parseModels(arena: Allocator, provider_id: []const u8, data: []const u8)var rows: std.ArrayList(pricing.ModelInfo) = .empty;for (items.array.items) |item| {if (item != .object) continue;- const id = util.strFieldObj(item.object, "id") orelse util.strFieldObj(item.object, "name") orelse continue;+ const raw_id = util.strFieldObj(item.object, "id") orelse util.strFieldObj(item.object, "name") orelse continue;+ // Google lists "models/gemini-3.8-flash" but answers to the bare id.+ const id = if (std.mem.startsWith(u8, raw_id, "models/")) raw_id["models/".len..] else raw_id;if (!validModelId(id)) continue;// Vercel AI Gateway lists image/video/embedding/rerank next to chat.// Anthropic uses type=model — only skip the known non-chat kinds.@@ -193,6 +195,8 @@ pub fn parseModels(arena: Allocator, provider_id: []const u8, data: []const u8)// max_tokens is the OUTPUT cap (128k on Opus 5) — never read it as a// window, or a 1M-context model would compact at ~102k.if (context == 0) context = positiveInt(item.object, "max_input_tokens");+ // Google's window. Its sibling outputTokenLimit is the OUTPUT cap, never this.+ if (context == 0) context = positiveInt(item.object, "inputTokenLimit");if (context == 0) context = bakedContext(provider_id, id) orelse pricing.default_context;rows.append(arena, .{.provider = provider_id,diff --git a/src/router_catalog_tests.zig b/src/router_catalog_tests.zigindex 8b21c217..766cc398 100644--- a/src/router_catalog_tests.zig+++ b/src/router_catalog_tests.zig@@ -25,7 +25,10 @@ test "OpenAI catalog configuration carries its models endpoint" {try std.testing.expectEqualStrings("https://gateway.codegraff.com/v1/models", modelsUrl(spec));for (provider.provider_specs) |candidate| {if (candidate.catalog != .openai) continue;- try std.testing.expect(candidate.kind == .openai);+ // `catalog` describes the MODEL-LIST shape, not the request wire: it+ // says /models answers with a `data`/`models` array this parser reads.+ // Google serves that list while talking Interactions for turns, so the+ // two are deliberately decoupled — only the endpoint is required.try std.testing.expect(candidate.models_url.len != 0);}}@@ -49,6 +52,29 @@ test "parseModels reads Vercel context_window and skips non-language types" {try std.testing.expectEqual(pricing.default_context, snapshot.models[1].context);}+test "parseModels strips Google's models/ prefix and takes the window from the baked row" {+ var state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer state.deinit();+ // Google's OpenAI-compat /models lists resource names and declares no window+ // at all, so the id must be bared for `--model gemini-3.8-flash` to match and+ // for bakedContext to find the 1M row.+ // Google's native list is `models`, not `data`, names each entry by its+ // resource name, and declares the window as inputTokenLimit — with+ // outputTokenLimit alongside it, which must never be read as the window.+ const snapshot = parseModels(state.allocator(), "google",+ \\{"models":[+ \\ {"name":"models/gemini-3.8-flash","inputTokenLimit":1048576,"outputTokenLimit":65536},+ \\ {"name":"models/not-in-the-baked-table"}+ \\]}+ ) orelse return error.TestUnexpectedResult;+ try std.testing.expectEqual(@as(usize, 2), snapshot.models.len);+ try std.testing.expectEqualStrings("gemini-3.8-flash", snapshot.models[0].name);+ try std.testing.expectEqual(@as(u64, 1_048_576), snapshot.models[0].context);+ // An unlisted window falls back to the baked table, then to the default.+ try std.testing.expectEqualStrings("not-in-the-baked-table", snapshot.models[1].name);+ try std.testing.expectEqual(pricing.default_context, snapshot.models[1].context);+}+test "parseModels reads OpenRouter context_length and include_reasoning" {var state = std.heap.ArenaAllocator.init(std.testing.allocator);defer state.deinit();diff --git a/src/schema.zig b/src/schema.zigindex 940551ba..713d6f36 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -236,7 +236,7 @@ pub fn isMetaName(name: []const u8) bool {// available. They live in `base_specs`' orbit rather than the root-only block// because a subagent has to be able to call them: the documented way to make// several images is one subagent per image, each calling `imagegen` once.-const optional_specs = [_]ToolSpec{+pub const optional_specs = [_]ToolSpec{.{ .name = imagegen.tool_name, .desc = imagegen.tool_desc, .schema = imagegen.tool_schema },};@@ -265,25 +265,10 @@ pub const tools_anthropic_sub_optional_remote = anthropicToolsJson(base_specs_oppub const tools_openai_sub_optional_remote = openaiToolsJson(base_specs_optional_remote);pub const tools_responses_sub_optional_remote = responsesToolsJson(base_specs_optional_remote);-/// The catalog a SUBAGENT is served, across both gates: `--no-local-tools`-/// subtracts, an available optional tool adds. Sole caller is Agent.toolsJson.-pub fn subToolsJson(kind: Provider.Kind, gated: bool) []const u8 {- const optional = tool_gates.anyAvailable();- return switch (kind) {- .anthropic => if (gated)- (if (optional) tools_anthropic_sub_optional_remote else tools_anthropic_sub_remote)- else- (if (optional) tools_anthropic_sub_optional else tools_anthropic_sub),- .openai => if (gated)- (if (optional) tools_openai_sub_optional_remote else tools_openai_sub_remote)- else- (if (optional) tools_openai_sub_optional else tools_openai_sub),- .responses => if (gated)- (if (optional) tools_responses_sub_optional_remote else tools_responses_sub_remote)- else- (if (optional) tools_responses_sub_optional else tools_responses_sub),- };-}+/// The catalog a SUBAGENT is served. Lives in schema_interactions.zig with the+/// Interactions catalogs (600-line ceiling here); re-exported so every existing+/// `schema.subToolsJson` caller keeps resolving.+pub const subToolsJson = @import("schema_interactions.zig").subToolsJson;/// Render built-in specs + discovered MCP tools into one provider-specific/// tools array (allocated with `out`). Used for the root agent at startup.@@ -351,6 +336,20 @@ pub fn writeToolEntry(s: *std.json.Stringify, kind: Provider.Kind, name: []consttry writeSchema(s, schema);try s.endObject();},+ // Interactions is the Responses entry without `strict`, which it+ // rejects as an unknown parameter.+ .interactions => {+ try s.beginObject();+ try s.objectField("type");+ try s.write("function");+ try s.objectField("name");+ try s.write(name);+ try s.objectField("description");+ try s.write(desc);+ try s.objectField("parameters");+ try writeSchema(s, schema);+ try s.endObject();+ },.openai => {try s.beginObject();try s.objectField("type");diff --git a/src/schema_interactions.zig b/src/schema_interactions.zignew file mode 100644index 00000000..3f1aa8c5--- /dev/null+++ b/src/schema_interactions.zig@@ -0,0 +1,63 @@+//! Google Interactions tool catalogs, and the subagent catalog selector for+//! every wire. Parked out of schema.zig, which sits at the 600-line ceiling.+//!+//! Interactions declares a tool in the Responses shape minus `strict` (the+//! endpoint rejects the whole request on an unknown field), so it needs its+//! own comptime catalogs rather than borrowing the Responses ones.++const schema = @import("schema.zig");+const render = @import("schema_render.zig");+const no_local_tools = @import("no_local_tools.zig");+const tool_gates = @import("tool_gates.zig");+const Provider = @import("provider.zig").Provider;++const interactionsToolsJson = render.interactionsToolsJson;+const ToolSpec = schema.ToolSpec;++const base = schema.base_specs;+const base_remote = no_local_tools.remoteSpecs(ToolSpec, &base);+const base_optional = base ++ schema.optional_specs;+const base_optional_remote = no_local_tools.remoteSpecs(ToolSpec, &base_optional);++pub const tools_interactions_sub = interactionsToolsJson(&base);+pub const tools_interactions_sub_remote = interactionsToolsJson(base_remote);+pub const tools_interactions_sub_optional = interactionsToolsJson(&base_optional);+pub const tools_interactions_sub_optional_remote = interactionsToolsJson(base_optional_remote);++/// The catalog a SUBAGENT is served, across both gates: `--no-local-tools`+/// subtracts, an available optional tool adds. Sole caller is Agent.toolsJson.+pub fn subToolsJson(kind: Provider.Kind, gated: bool) []const u8 {+ const optional = tool_gates.anyAvailable();+ return switch (kind) {+ .anthropic => if (gated)+ (if (optional) schema.tools_anthropic_sub_optional_remote else schema.tools_anthropic_sub_remote)+ else+ (if (optional) schema.tools_anthropic_sub_optional else schema.tools_anthropic_sub),+ .openai => if (gated)+ (if (optional) schema.tools_openai_sub_optional_remote else schema.tools_openai_sub_remote)+ else+ (if (optional) schema.tools_openai_sub_optional else schema.tools_openai_sub),+ .responses => if (gated)+ (if (optional) schema.tools_responses_sub_optional_remote else schema.tools_responses_sub_remote)+ else+ (if (optional) schema.tools_responses_sub_optional else schema.tools_responses_sub),+ .interactions => if (gated)+ (if (optional) tools_interactions_sub_optional_remote else tools_interactions_sub_remote)+ else+ (if (optional) tools_interactions_sub_optional else tools_interactions_sub),+ };+}++const std = @import("std");++test "the interactions catalog is the responses catalog without strict" {+ // Same tools, same order, same schemas — only the field Google rejects differs.+ try std.testing.expect(std.mem.indexOf(u8, schema.tools_responses_sub, "\"strict\":false") != null);+ try std.testing.expect(std.mem.indexOf(u8, tools_interactions_sub, "strict") == null);+ try std.testing.expect(std.mem.indexOf(u8, tools_interactions_sub, "\"type\":\"function\",\"name\":\"bash\"") != null);+ var parsed = try std.json.parseFromSlice(std.json.Value, std.testing.allocator, tools_interactions_sub, .{});+ defer parsed.deinit();+ var responses_parsed = try std.json.parseFromSlice(std.json.Value, std.testing.allocator, schema.tools_responses_sub, .{});+ defer responses_parsed.deinit();+ try std.testing.expectEqual(responses_parsed.value.array.items.len, parsed.value.array.items.len);+}diff --git a/src/schema_render.zig b/src/schema_render.zigindex 093db248..e49f1069 100644--- a/src/schema_render.zig+++ b/src/schema_render.zig@@ -48,6 +48,22 @@ pub fn responsesToolsJson(comptime specs: anytype) []const u8 {}}+/// Google Interactions: the Responses shape minus `strict`. The endpoint+/// validates strictly and rejects the whole request on an unknown field+/// ("Unknown parameter 'strict' at 'tools[0]'"), so the two cannot share a+/// catalog even though every other byte matches.+pub fn interactionsToolsJson(comptime specs: anytype) []const u8 {+ comptime {+ var out: []const u8 = "[";+ for (specs, 0..) |t, i| {+ if (i > 0) out = out ++ ",";+ out = out ++ "{\"type\":\"function\",\"name\":\"" ++ t.name +++ "\",\"description\":\"" ++ t.desc ++ "\",\"parameters\":" ++ t.schema ++ "}";+ }+ return out ++ "]";+ }+}+test "renderers emit one entry per spec in each provider shape" {const Spec = struct { name: []const u8, desc: []const u8, schema: []const u8 };const specs = [_]Spec{diff --git a/src/side_question_tests.zig b/src/side_question_tests.zigindex 24bf31f4..dfd29e1a 100644--- a/src/side_question_tests.zig+++ b/src/side_question_tests.zig@@ -34,6 +34,7 @@ fn provider(kind: Provider.Kind) Provider {.anthropic => "anthropic",.openai => "openai",.responses => "codex",+ .interactions => "google",},.kind = kind,.auth = .bearer,diff --git a/src/spec_prompt_cache_conformance.zig b/src/spec_prompt_cache_conformance.zigindex 4994706a..3891174a 100644--- a/src/spec_prompt_cache_conformance.zig+++ b/src/spec_prompt_cache_conformance.zig@@ -57,7 +57,13 @@ fn hasCacheControl(body: []const u8) bool {return std.mem.indexOf(u8, body, "\"cache_control\":{\"type\":\"ephemeral\"}") != null;}-fn wantsKey(kind: provider_mod.Provider.Kind) bool {+fn wantsKey(id: []const u8, kind: provider_mod.Provider.Kind) bool {+ // Google validates the payload strictly and rejects the entire request on+ // an unknown field, so it is the one openai-wire provider that cannot carry+ // a partition key ("Unknown name \"prompt_cache_key\""). It caches+ // implicitly instead. Every other openai/responses provider still must pin+ // one — this is a named exception, not a relaxed rule.+ if (std.mem.eql(u8, id, "google")) return false;return kind == .openai or kind == .responses;}@@ -82,7 +88,7 @@ test "prompt cache: every baked provider pins a key or Anthropic prefix" {const kid = try child.buildBody(null, false, true, true);defer std.testing.allocator.free(kid);- if (wantsKey(spec.kind)) {+ if (wantsKey(spec.id, spec.kind)) {const k1 = cacheKeyIn(first) orelse {std.debug.print("\n{s} ({s}): missing prompt_cache_key\n", .{ spec.id, @tagName(spec.kind) });return error.MissingPromptCacheKey;diff --git a/src/spec_provider_conformance.zig b/src/spec_provider_conformance.zigindex 9ea3b0cf..fa09a2fa 100644--- a/src/spec_provider_conformance.zig+++ b/src/spec_provider_conformance.zig@@ -13,6 +13,7 @@ fn kindName(k: Provider.Kind) []const u8 {.anthropic => "anthropic",.openai => "openai",.responses => "responses",+ .interactions => "interactions",};}@@ -20,6 +21,7 @@ fn authName(a: Provider.Auth) []const u8 {return switch (a) {.x_api_key => "x_api_key",.bearer => "bearer",+ .goog_api_key => "goog_api_key",};}diff --git a/src/spec_structured_output_conformance.zig b/src/spec_structured_output_conformance.zigindex 7f1f4d8d..df0a388e 100644--- a/src/spec_structured_output_conformance.zig+++ b/src/spec_structured_output_conformance.zig@@ -23,10 +23,12 @@ fn agentFor(arena: std.mem.Allocator, wire: []const u8) !Agent {.anthropic => "anthropic",.openai => "deepseek",.responses => "xai",+ .interactions => "google",};const model: []const u8 = switch (kind) {.anthropic => "claude-sonnet-5",.openai => "deepseek-v4-flash",+ .interactions => "gemini-3.8-flash",.responses => "grok-4.6",};return .{diff --git a/src/title.zig b/src/title.zigindex 037f3104..4d47c311 100644--- a/src/title.zig+++ b/src/title.zig@@ -87,6 +87,9 @@ pub fn printSessionHeader(w: *Io.Writer, title: []const u8, folder: []const u8)/// codex/responses a `response.reasoning_summary_text.delta`.pub fn reasoningDelta(kind: Provider.Kind, obj: std.json.ObjectMap) []const u8 {return switch (kind) {+ // Gemini never streams reasoning PROSE — a thought step carries only an+ // opaque signature, so there is nothing to show in the thinking panel.+ .interactions => "",.anthropic => blk: {const d = obj.get("delta") orelse break :blk "";if (d != .object) break :blk "";@@ -130,6 +133,24 @@ pub fn assistantText(kind: Provider.Kind, root: std.json.ObjectMap) []const u8 {}break :blk "";},+ // Interactions returns execution steps; the answer is the text parts of+ // the model_output step (thought steps carry only an opaque signature).+ .interactions => blk: {+ const steps = root.get("steps") orelse break :blk "";+ if (steps != .array) break :blk "";+ for (steps.array.items) |step| {+ if (step != .object) continue;+ const st = if (step.object.get("type")) |t| (if (t == .string) t.string else "") else "";+ if (!std.mem.eql(u8, st, "model_output")) continue;+ if (step.object.get("content")) |c| if (c == .array) {+ for (c.array.items) |part| {+ if (part != .object) continue;+ if (part.object.get("text")) |txt| if (txt == .string) break :blk txt.string;+ }+ };+ }+ break :blk "";+ },.openai => blk: {const choices = root.get("choices") orelse break :blk "";if (choices != .array or choices.array.items.len == 0) break :blk "";diff --git a/src/vision.zig b/src/vision.zigindex f003a31e..99c48e02 100644--- a/src/vision.zig+++ b/src/vision.zig@@ -113,6 +113,7 @@ pub fn imageMessages(arena: Allocator, kind: Provider.Kind, text: []const u8, im}try ib.put(arena, "source", .{ .object = src });},+ .interactions => try @import("interactions_steps.zig").imagePart(arena, &ib, img),.openai => {try ib.put(arena, "type", .{ .string = "image_url" });var iu: std.json.ObjectMap = .empty;diff --git a/src/vision_queue.zig b/src/vision_queue.zigindex 6fca6083..6e118f6a 100644--- a/src/vision_queue.zig+++ b/src/vision_queue.zig@@ -277,6 +277,13 @@ test "remote URL and base64 parts become native provider image blocks (#615)" {const content = msg.object.get("content").?.array.items;try std.testing.expectEqual(@as(usize, 3), content.len);switch (kind) {+ // Interactions carries raw base64 + mime_type, with a remote URL+ // degraded to a text marker (no proven inline form on that wire).+ .interactions => {+ try std.testing.expectEqualStrings("[image: https://images.test/code.png]", content[1].object.get("text").?.string);+ try std.testing.expectEqualStrings("aGVsbG8=", content[2].object.get("data").?.string);+ try std.testing.expectEqualStrings("image/png", content[2].object.get("mime_type").?.string);+ },.responses => {try std.testing.expectEqualStrings("https://images.test/code.png", content[1].object.get("image_url").?.string);try std.testing.expectEqualStrings("data:image/png;base64,aGVsbG8=", content[2].object.get("image_url").?.string);