magi-code 0.77.1

Repository-aware CLI coding agent for terminal work
Documentation
# Provider guide

## Scope

Owns provider construction, request formats, HTTP transport, catalogs, and stream parsing.

## Where to look

| Task | Path |
| --- | --- |
| Validate selection and construct providers | `factory.rs` |
| Conversation and request types | `request.rs` |
| Codex and compatible endpoints | `openai/codex.rs`, `openai/compatible.rs` |
| Request bodies, headers, model discovery | `openai/bodies.rs`, `openai/headers.rs`, `openai/catalog.rs` |
| Anthropic Messages and parser | `anthropic.rs`, `anthropic/stream.rs` |
| Attempts, cancellation, semantic timeout | `openai_stream.rs` |
| Blocking HTTP and byte-idle watchdog | `transport.rs` |
| SSE framing and diagnostics | `sse.rs` |
| Chat/Responses event assembly | `stream/mod.rs`, `stream/chat_completions.rs`, `stream/openai_responses.rs` |
| Inline calls and reasoning summaries | `stream/inline_tools.rs`, `stream/reasoning.rs` |

## Local rules

- The agent preparation path selects the provider; the factory validates and builds it. The shared `Provider` trait is defined in `openai/mod.rs` despite its family-specific location.
- Keep Codex OAuth/account headers, Anthropic API-key headers, and custom env/no-auth headers separate. Keep Chat Completions and Responses body builders distinct.
- Apply the root manual companion's Codex replay sanitization in `openai/bodies.rs`; retain function-call and function-output items.
- Parsed text, reasoning, tool, usage, or completion events determine semantic progress. Receiving bytes or Fast service-tier metadata alone does not.
- Preserve call ids, partial arguments, response-item order, and terminal events. Keep SSE-event and argument buffers bounded; retry decisions belong above parsers.
- Distinguish transport byte-idle failures from semantic-progress failures; use the configured request timeout rather than assuming one timeout for all workloads.
- Keep catalog and wire diagnostics redacted. Terminal streaming-redaction boundaries belong to output renderers, not these parsers.

## Verification landmarks

Request/auth/replay tests live in `openai/tests.rs` and `tests.rs`; parser tests also live inline and in `anthropic/stream/tests.rs`.