From Local Deep Agent to Callable Service: CLI vs API Integration Guide

The article explains how to transition Deep Agents from a local CLI debugging tool to production-ready callable services, comparing CLI, Python SDK, LangGraph service, and ACP, and provides practical code examples, deployment steps, and a pre‑launch checklist for secure enterprise integration.

Tech Ocean
Tech Ocean
Tech Ocean
From Local Deep Agent to Callable Service: CLI vs API Integration Guide

Why the entry point matters

After nine days covering Agent capabilities—planning, file handling, backend, execution, sub‑agents, memory, permissions, skills, and HITL—the next question is how others can call the Agent. Do not mix the different entry points.

Four main entry options and their typical use cases:

CLI : local debugging, prompt testing, observing tool behavior.

Python SDK : embed the Agent into your own backend services.

LangGraph service : expose HTTP, streaming calls and manage threads/runs.

ACP : integrate with editors, terminals, or desktop clients.

For internal enterprise services, the recommended progression is: start with the Python SDK, then consider LangGraph service, and finally add integrations such as enterprise WeChat, Feishu, web consoles, or IDE plugins. As entry points increase, place authentication, rate‑limiting, tenant isolation, logging, and cost tracking in a middle layer.

1. SDK is not the same as CLI

The deepagents Python package provides the create_deep_agent SDK. The command‑line interface lives in a separate deepagents-cli package and is not guaranteed to be installed with the SDK.

uv tool install 'deepagents-cli[anthropic]'
deepagents --model anthropic:claude-sonnet-4-6

CLI is suitable for:

Quick prompt testing

Temporarily switching models

Observing tool‑call behavior

Local validation of Agent workflows

It is not recommended as a production API gateway or a multi‑tenant service entry.

2. Python SDK is the most stable integration point

To embed Deep Agents into your backend, start with the Python API:

from deepagents import create_deep_agent

agent = create_deep_agent(
    model="anthropic:claude-sonnet-4-6",
    system_prompt="You are an enterprise knowledge‑base assistant; answers must cite sources."
)

result = agent.invoke({
    "messages": [{"role": "user", "content": "Summarize the onboarding document's permission request process"}]
})
print(result["messages"][-1].content)

For asynchronous services use ainvoke:

async def chat(message: str):
    result = await agent.ainvoke({
        "messages": [{"role": "user", "content": message}]
    })
    return result["messages"][-1].content

This path keeps control in your hands: you can plug in authentication, rate‑limiting, logging, billing, tracing, error handling, and data masking using your existing backend infrastructure, which is more reliable than wrapping the CLI.

3. Understanding LangGraph service‑ification

Deep Agents returns a compiled LangGraph graph, which can be served like any LangGraph application. Create a langgraph.json that points to your Agent object:

{
  "dependencies": ["./pyproject.toml"],
  "graphs": {
    "assistant": "./agent.py:agent"
  }
}

Example agent.py:

from deepagents import create_deep_agent

agent = create_deep_agent(
    model="anthropic:claude-sonnet-4-6",
    system_prompt="You are an internal R&D assistant."
)

Run the development server:

uv add langgraph-cli
uv run langgraph dev --port 2024

The server provides thread creation, run execution, and streaming of events.

4. Calling the service with langgraph‑sdk

Synchronous call example:

from langgraph_sdk import get_sync_client

client = get_sync_client(url="http://localhost:2024")
thread = client.threads.create()
result = client.runs.wait(
    thread_id=thread["thread_id"],
    assistant_id="assistant",
    input={"messages": [{"role": "user", "content": "Help me outline the repository's startup steps"}]}
)
print(result["messages"][-1]["content"])

Streaming call (useful for front‑end chat UI, IDE plugins, or progress panels):

for chunk in client.runs.stream(
    thread_id=thread["thread_id"],
    assistant_id="assistant",
    input={"messages": [{"role": "user", "content": "Generate an API specification"}]},
    stream_mode="updates",
):
    print(chunk)

Streaming lets users see intermediate states, tool calls, and partial results, which is reassuring for long‑running tasks.

5. ACP is not a generic REST API

ACP (Agent Client Protocol) targets editors, terminals, and desktop clients, providing a uniform protocol for Agent interaction. It is not a replacement for a full‑featured business REST API.

Business system calls → wrap your own backend API or LangGraph HTTP.

Front‑end chat UI calls → backend API + LangGraph service.

IDE or desktop client calls → use ACP.

Auth, billing, gray‑release, audit → implement in your own business backend.

Do not treat ACP as a universal deployment protocol; it solves client integration, not all production backend concerns.

6. Pre‑launch minimal checklist

Model configuration : avoid hard‑coding keys; use environment variables or secret management.

State recovery : configure a checkpointer for long‑running tasks.

File capabilities : define backend + permissions boundaries.

Command execution : use LocalShell locally, switch to a sandbox in production.

Human approval (HITL) : add HITL for execute and edit_file actions.

Observability & audit : log tool calls, latency, exit codes, and model usage.

API gateway : implement auth, rate‑limiting, tenant isolation, and error codes.

Cost control : track usage by user, tenant, and task type.

Running locally with the CLI does not mean it is ready for company‑wide deployment; define user identity, data access scope, maximum cost per run, and rollback strategy before production.

7. Integrating with enterprise WeChat, Feishu, web console, or IDE plugins

Recommended architecture:

User entry
  → Business API
  → Auth / Rate‑limit / Tenant isolation / Log masking
  → LangGraph service or Python SDK
  → Deep Agents

This keeps user management, data permissions, and audit logs within your familiar backend rather than exposing the Agent entry directly.

10‑day recap

The ten‑day series focused on moving an Agent from a demo to an engineering‑grade service. The core value of Deep Agents is providing default Agent capabilities; successful production requires backend engineering to handle permissions, state, logging, cost, and user entry.

Final recommendation

For long‑term team use, embed Deep Agents into your backend first, then service‑ify with LangGraph, and finally expand entry points. The more entry points you expose, the more robust the middle‑layer business API must be.

How to get the code

Reply with "DeepAgents" to receive the code repository and related materials such as CLI examples, LangGraph configuration, and the pre‑launch checklist.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIAPILangGraphPython SDKAgent IntegrationDeep Agents
Tech Ocean
Written by

Tech Ocean

Focused on AI programming, sharing ready-to-use development efficiency solutions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.