Skip to content

Proposal: Split SDK (local-only) vs Recipes (server-side A2A agents) #218

Closed

Description

@xingyaoww

Proposal: Split SDK (local-only) vs Recipes (server-side A2A agents)

Context

Right now our SDK (openhands-sdk) supports building agents, conversations, and tools locally.
We have been debating how to support remote execution (e.g., agents running in a container or service, callable via API).

We explored designs like LocalRunLoop and RemoteRuntimeLoop (#213), where a Tool spec on the client would be “re-bound” to executors on the server.

But this introduces a lot of complexity:

  • Two execution modes (local vs remote) with different semantics
  • Hard to support nested agents (e.g., one conversation creating another conversation and wiring it as a tool)
  • Bridge logic on the client to forward calls across runtime boundaries
  • Debuggability and lifecycle management are much harder

We realized: trying to make SDK both local and remote leads to complexity and breakage.
Instead, we can split responsibilities.


Proposal

1. SDK remains local-only

  • Keep the SDK slim and stable:
    • LLM, Tool, Agent, Conversation, etc.
    • .create() binds executors locally
    • Users can still assemble arbitrary agents and conversations in Python
  • No remote execution layer in the SDK
    • No RemoteRunLoop
    • No Tool proxy executors
  • The SDK is always local-first.

2. Introduce openhands/recipe

  • A new package that contains pre-defined recipes for “production agents”.
  • Each recipe:
    • Assembles an Agent with a curated list of tools
    • Wraps controller/orchestrator logic (how conversations are managed, callbacks, multi-agent logic if needed)
    • Exposes a simple API surface (start, send_message, run, pause, status, events, close)
  • Recipes are opinionated, high-level constructs.
    Example: DevAgent that bundles BashTool, FileEditorTool, TaskTrackerTool.

3. Expose recipes via A2A protocol

  • Each recipe is exported as an A2A Agent.
  • Mapping:
    • Agent → A2A Agent
    • Tools → A2A Capabilities
    • Conversation lifecycle → A2A invoke calls
    • Events / Status → A2A state + event streams
  • This makes recipes interoperable with other A2A-compatible systems.
  • All server-side logic (executor binding, workspace, safety, auth, logging) stays in the recipe implementation.
  • We get a bunch of A2A feature for free (mostly), e.g., PushNotification/callback that we want here
  • Client applications will consume these agents directly through A2A.
    They can also wrap their own custom server (FastAPI, Flask, gRPC, etc.) that internally uses A2A to interact with recipes.

Benefits

  • Clear boundaries
    SDK is only for local agent composition. Recipes handle remote exposure.

  • Simplicity
    No dual-mode runtime. No remote executor plumbing.

  • Interoperability
    Using A2A means agents can call each other across systems in the future.

  • Production readiness
    Recipes can enforce safety limits, tenancy, logging, and auditing without burdening SDK users.


Example Layout

openhands-sdk/          # local SDK
  Agent, Tool, Conversation, LLM, etc.

openhands-recipe/       # new package
  /recipes/
    /dev_agent/
      recipe.py         # assemble agent + tools
      policy.py         # safety, config
  /a2a/
    adapter.py          # FastAPI adapter → A2A protocol

Example UX

Local SDK (unchanged)

from openhands.sdk import LLM, Agent, Conversation, Message, TextContent
from openhands.tools import BashTool, FileEditorTool, TaskTrackerTool

llm = LLM(model="claude-sonnet-4", api_key="...")
tools = [BashTool.create(...), FileEditorTool.create(), TaskTrackerTool.create()]

agent = Agent(llm=llm, tools=tools)
conv = Conversation(agent)
conv.send_message(Message(role="user", content=[TextContent(text="Hello!")]))
conv.run()

Remote via A2A

# Client using an A2A library
session = a2a.create_session(agent_id="openhands.dev_agent")
a2a.invoke(agent_id, session.id, {"type":"send_message","text":"Hello!"})
a2a.invoke(agent_id, session.id, {"type":"run"})
status = a2a.invoke(agent_id, session.id, {"type":"status"})
events = a2a.invoke(agent_id, session.id, {"type":"events","after":0})

Next Steps

  1. Create openhands-recipe package.
  2. Implement one reference recipe (dev_agent) that uses Bash/FileEditor/TaskTracker.
  3. Add FastAPI A2A adapter to expose recipes.
  4. Support minimal lifecycle verbs: send_message, run, status, events, pause, close.
  5. Iterate: add streaming support, safety limits, multi-agent orchestration.

Bottom line:

  • SDK stays local-only, no remote runtime loop.
  • Recipes in a new package assemble production agents and are exposed via A2A protocol.
  • Client apps consume agents directly through A2A, optionally wrapping their own servers.
  • This gives us a clean architecture, easier dev UX, and future interoperability.

Activity

  1. xingyaoww commented on Sep 12, 2025

    @xingyaoww
    ContributorAuthor

    The production story:

    1. We build the "openhands-production-agent" into a binary
    2. On the application client side (e.g., OH GUI, CLI): we (1) luanch the agent binary with appropriate arguments, (2) connect to A2A via A2A client SDK (e.g. using async/whatever way we want), (3) we might need to add additional endpoints for our custom events structure/stream
  2. enyst commented on Sep 12, 2025

    @enyst
    Member

    How will the local + remote runtime look like?

  3. xingyaoww commented on Sep 13, 2025

    @xingyaoww
    ContributorAuthor

    @enyst i think it will be something like #194

    Basically ALL SDK is "local".

    If you want to do remote runtime, you need to use an opinionated server written using SDK (eg #194) - then start a docker image, copy the server binary into it, and then start the docker. Then the client will simply interact with the docker to run tasks

  4. enyst commented on Sep 15, 2025

    @enyst
    Member

    Do we still need to

    copy the server binary into it?

    It sounds strange to me, but I think we don't anymore?

  5. xingyaoww commented on Sep 16, 2025

    @xingyaoww
    ContributorAuthor

    @enyst i think we sill might need something like this, but it is just that this should be done in the docker build phase, shouldn't need to be explicit though.

    In context of this PR, some updates are:

    Seems to me that we've reached certain concensus to keep going, so we can probably close this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions