Metadata-Version: 2.4
Name: deepagents_serve
Version: 0.1.0
Summary: Universal agent server. Wraps any LangGraph graph and exposes it over standard agent protocols — Vercel AI SDK, Claude Code, TUIs, and more.
License-Expression: MIT
Project-URL: Homepage, https://github.com/FengJi2021/deepagents-serve
Project-URL: Repository, https://github.com/FengJi2021/deepagents-serve
Project-URL: Issues, https://github.com/FengJi2021/deepagents-serve/issues
Keywords: agents,ai,llm,langgraph,langchain,agent-server,vercel-ai,streaming
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <4.0,>=3.11
Description-Content-Type: text/markdown
Requires-Dist: starlette>=0.46.0
Requires-Dist: uvicorn>=0.34.0
Requires-Dist: langgraph>=0.4.0
Requires-Dist: langchain-core>=0.3.0

# deepagents-serve

Universal agent server. Wraps any LangGraph graph and exposes it over standard agent protocols — Vercel AI SDK, Claude Code, TUIs, and more.

## Quick start

```python
from deepagents_serve import DeepAgentsServeApp
from deepagents import create_deep_agent
import uvicorn

agent = create_deep_agent(
    model="anthropic:claude-opus-4-8",
    skills=["myskillsregistry/skills"],
    system_prompt="You are a helpful assistant."
)

app = DeepAgentsServeApp(agent)

uvicorn.run(app.build(), host="0.0.0.0", port=8000)
```

---

## Endpoint design

### `POST /chat/stream`

Stateless. One request, one SSE stream, done. No session state is kept between calls.

**Request**

```json
{
  "messages": [
    {"role": "user", "content": "List the files in the working directory."}
  ]
}
```

**Response** — `Content-Type: text/event-stream`

Uses the [Vercel AI Data Protocol](https://sdk.vercel.ai/docs/ai-sdk-ui/stream-protocol). Each line is `data: <json>`:

```text
data: {"type": "text-start", "id": "msg_01"}
data: {"type": "text-delta", "id": "msg_01", "delta": "Here are the files:\n"}
data: {"type": "text-end", "id": "msg_01"}

data: {"type": "tool-input-start", "toolCallId": "tc_01", "toolName": "bash"}
data: {"type": "tool-input-delta", "toolCallId": "tc_01", "inputTextDelta": "{\"command\":\"ls\"}"}
data: {"type": "tool-output-available", "toolCallId": "tc_01", "output": "README.md\nsrc/"}

data: {"type": "reasoning-start", "id": "r_01"}
data: {"type": "reasoning-delta", "id": "r_01", "delta": "I should list the files..."}
data: {"type": "reasoning-end", "id": "r_01"}

data: {"type": "error", "errorText": "something went wrong"}
data: {"type": "abort", "reason": "user cancelled"}
data: {"type": "finish"}
```

---

## Signal diagram

```text
Client (Vercel SDK / Claude Code / TUI)
  │
  │  POST /chat/stream
  │  {"messages": [{"role": "user", "content": "..."}]}
  ▼
┌──────────────────┐
│  Input Parser    │  extract last user message from messages array
└────────┬─────────┘
         │ {"role": "user", "content": "..."}
         ▼
┌──────────────────┐
│  LangGraph Graph │  graph.astream({"messages": [...]}, stream_mode=["messages"])
└────────┬─────────┘
         │ (stream_part, metadata) chunks
         ▼
┌──────────────────┐
│  Normaliser      │  LangGraph messages → canonical AgentEvent
│                  │
│  AIMessage       │→  TextDelta | ReasoningDelta
│  ToolCall        │→  ToolInputDelta
│  ToolMessage     │→  ToolOutputAvailable
│  Error           │→  Error | Abort
└────────┬─────────┘
         │ AgentEvent
         ▼
┌──────────────────┐
│  Vercel Adapter  │  AgentEvent → Vercel SSE stream parts
└────────┬─────────┘
         │ text/event-stream
         ▼
Client
```

---

## Roadmap

**Near-term**

- [ ] Input parsing — read request body, extract messages
- [ ] Complete normaliser — tool calls, tool results, reasoning deltas from LangGraph
- [ ] Request validation — reject malformed payloads at the boundary

**Protocol compatibility**

- [ ] Claude Managed Agents endpoints — `/v1/sessions`, `/v1/sessions/{id}/events`, `/v1/sessions/{id}/events/stream`
- [ ] Claude Managed Agents SSE encoding — `agent.message`, `agent.tool_use`, `session.status_idle` event types
- [ ] Agent metadata endpoint — `GET /v1/agents/default`

**Statefulness**

- [ ] Session layer — LangGraph `thread_id` checkpointing, `session_id` → `thread_id` mapping
- [ ] Multi-turn conversations — persist conversation history across requests
- [ ] Interrupt support — `user.interrupt` event stops graph mid-execution

**Deployment**

- [ ] kagent packaging — Kubernetes-compatible worker pattern

**Eval**

- [ ] Event history capture — persist full turn events with timestamps and token counts
- [ ] Session replay — re-run a captured session for regression testing

**Skills**

- [ ] Skill registry compatibility — discover and invoke skills from a registry
- [ ] Finetune on skills — export session history as structured training data
