graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
docs(adr): 0002 — xAI defaults to the Responses wire
Rach Pradhanaf107dd06431
diff --git a/docs/adr/0002-xai-defaults-to-the-responses-wire.md b/docs/adr/0002-xai-defaults-to-the-responses-wire.mdnew file mode 100644index 00000000..dd1b3ea6--- /dev/null+++ b/docs/adr/0002-xai-defaults-to-the-responses-wire.md@@ -0,0 +1,43 @@+# 0002. xAI defaults to the Responses wire (WS + server compaction)++Status: accepted 2026-08-15++## Context++grok support (#502) landed with the Responses wire behind+`GRAFF_XAI_WIRE=responses` while a harder-recall A/B decided the default.+The A/B (24 planted identifiers in ~13k-token conversations, 12 quizzed,+both compaction paths): with salience cues both arms recalled 12/12; with+facts buried as incidental asides the server blob stayed 12/12 while the+client summary dropped the earliest fact (11/12, blank rather than+hallucinated). Wall-clock and cost were equivalent per turn (blob replay+costs more input tokens than a summary but is lossless by construction).+The one blocker was #505: duplicate MCP tool definitions (a deferred server+start racing the eager codedb-pro companion) made strict Responses+endpoints reject every request; fixed alongside the flip.++## Decision++`g_xai_responses` defaults to true: xAI sessions run on+api.x.ai/v1/responses, which gives WebSocket turns (with the WS→SSE+fallback ladder), first-party server-side compaction for both+autocompaction and manual `/compact` (#503), and structured outputs.+`GRAFF_XAI_WIRE=chat` (any value other than `responses`) opts a session+back onto chat completions.++## Consequences++- Lossless compaction by default; the intent-aware client summary remains+ the fallback when the endpoint refuses or fails, and the chat wire keeps+ it as primary.+- WS eligibility stays an explicit provider list (codex, xai) — Platform+ OpenAI is Responses-kind but has no WS server and must never probe one.+- Chaining via previous_response_id stays codex-only: xAI's store:false ++ previous_response_id stalls server-side (probed live), so xai rides+ full-resend over the held socket.+- Revisit if xAI's wire diverges from OpenAI Responses semantics or the+ compact endpoint's blob replay pricing changes the cost picture.++Evidence: #502, #503, #505, the recall A/B kit (session scratchpad+recall-ab/), ADR [0001](0001-structured-outputs-are-a-formatting-step.md)+for the structured-outputs half of the wire.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 18f8f881..beac34df 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -12,6 +12,7 @@ record only when you need the evidence or the edge cases.| ADR | The rule ||---|---|| [0001](0001-structured-outputs-are-a-formatting-step.md) | Structured output is a final formatting step. Never constrain the agentic phase with a schema grammar, and do not use `--output-schema` unless a program consumes the result. |+| [0002](0002-xai-defaults-to-the-responses-wire.md) | xAI runs on the Responses wire by default (WS turns, lossless server compaction). `GRAFF_XAI_WIRE=chat` opts out; WS stays an explicit provider list. |## When to write one