feat(api-rs): Anthropic Messages-compatible /v1/messages ingress#702
Open
tarrencev wants to merge 1 commit into
Open
feat(api-rs): Anthropic Messages-compatible /v1/messages ingress#702tarrencev wants to merge 1 commit into
tarrencev wants to merge 1 commit into
Conversation
Contributor
Author
|
@gakonst lmk if this is of interest to you. I think it is a cool feature, allowing driving Centaur threads from Codex / Claude + supporting handoff from Slack to native clients. We can also improve it to support local tool calling so the model has a combination of Centaur + local dev env |
b221d50 to
7cb87dc
Compare
d0b7050 to
fdc261e
Compare
Expose centaur's durable, thread-keyed session control plane behind an Anthropic Messages-compatible POST /v1/messages so any Anthropic SDK client or `claude -p` (via ANTHROPIC_BASE_URL) can drive a fully-configured centaur thread (tools, sandbox, durability). - Thread continuity via X-Centaur-Thread-Key (absent -> api:<uuid>). - Honors `model` and `system` (first-request-wins), threading them into the sandbox harness env (CLAUDE_MODEL, CENTAUR_EXTRA_SYSTEM_PROMPT). - Streaming (SSE) and non-streaming responses via an AnthropicTranslator that maps harness output to Anthropic content blocks. Handles both harness event shapes: claude (Anthropic-shaped) and codex, including the deployed Rust harness-server's slash-method/params events (item/agentMessage/delta, item/reasoning/textDelta, item/completed). - Drives the turn off the last user message so clients (e.g. Claude Code) that append a trailing system-role message in messages[] are handled. Validated end-to-end against the c7e deployment with `claude -p`: basic replies, tool use (inner agent runs shell commands), and model selection (requested model lands as CLAUDE_MODEL in the spawned sandbox).
fdc261e to
01ed944
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes centaur's durable, thread-keyed session control plane behind an Anthropic Messages-compatible
POST /v1/messages, so any Anthropic SDK client orclaude -p(viaANTHROPIC_BASE_URL) can drive a fully-configured centaur thread (tools, sandbox, durability) through the standard Messages API.Now fully implemented and validated end-to-end on a live deployment. This folds in the model/system support (previously a stacked follow-up) plus the harness-output and client-compatibility fixes found while validating with
claude -p.What it does
POST /v1/messages(Anthropic Messages shape), registered alongside/api/session/*; streaming (SSE) and non-streaming.X-Claude-Code-Session-Idheader (the same id it uses for--resume/--continue) → threadapi:claude:<session-id>, so a resumed CLI session continues the same durable thread and warm sandbox. No custom header to manage; absent → a freshapi:<uuid>thread.modelandsystem(first-request-wins): threaded into the sandbox harness env (CLAUDE_MODEL;CENTAUR_EXTRA_SYSTEM_PROMPTappended afterAGENTS.md).toolsare accepted but centaur owns the in-sandbox tools.AnthropicTranslatormaps harness output → Anthropic content-block stream events, handling both harness shapes:assistant/userevents);item.agentMessage.deltashape and the Rust harness-server's slash-method/paramsevents (item/agentMessage/delta,item/reasoning/textDelta,item/completed). Text + reasoning +tool_use+tool_result→ content blocks.usermessage, so clients like Claude Code that append a trailingsystem-role message inmessages[]work.Validation
End-to-end against a live deployment with
claude -p(ANTHROPIC_BASE_URL→ the ingress):Reply PONG→PONG);modellands asCLAUDE_MODELin the spawned sandbox.cargo fmt --check·clippy -D warnings·cargo testgreen (translator unit cases for both harness shapes + streaming/non-streaming integration via the stdout-scripting backend; harness-server system-prompt test).Follow-ups (out of scope)
x-api-keyauth on/v1/messages(currently network-gated like/api/session/*).toolsexecute caller-side via an MCP bridge) — designed, not in this PR.