#Host and platform integration
A FLOW host lets your application invoke a reusable method with input and receive an outcome with data. The method can use code, Agent judgment, or other methods. Your host selects its implementation and supplies its local powers and execution context.
This guide is for maintainers adding that ability to a coding agent or platform. For writing a method instead, start with the SDK tutorials.
#Component entry and dependency invocation
Run/0 has two requests because the caller and host supply different information:
The host resolves the slot, checks its grants, and constructs the selected implementation's context. The caller does not choose its credentials, settings, attachments, scratch directory, or deadline. A child has its own context and inherits the remaining deadline; it does not implicitly inherit other powers.
Every launched component receives flow/run, including Flow B. A child is an
invocation relationship, not a separate package type. A slot can also select a
host-provided implementation without launching another component process; its
input, result, authority and owned-work obligations still apply.
For an author, the SDK exposes handle(handler) to receive an invocation and
context.call(...) to invoke a dependency. See Run/0
for the wire contract and Run SDK/0 for that authoring API.
#Place the host alongside ACP
The Agent Client Protocol (ACP) connects a client, such as an editor, to a coding agent. FLOW connects a host to callable method implementations. These roles are independent; ACP support does not supply a Run/0 host.
In either placement, implement the same FLOW boundary. When supplying an ACP-backed dependency, an adapter must translate the dependency's declared input into the Agent's session/prompt API and validate the completed answer against its result contract. ACP updates are observations; they are not a FLOW terminal result. Own the session through completion, failure and cancellation, and distinguish a settled failure from uncertain dispatch. Use separate Agent contexts when the method requires that isolation.
The application chooses the Agent route and its grants. An arbitrary slot name or model response must not create a new route. FLOW does not define a universal ACP adapter, provider configuration, or host admission UI. Consult the ACP documentation for its session protocol; use the dependency's actual invocation contract for its data.
#Walkthrough: Servicing a declared slot with an ACP Agent
Consider a caller Flow that declares a dependency slot summarizer in its
FLOW.meta.json:
When running in an ACP Client orchestrator, the host routes calls for
slot: "summarizer" to an admitted ACP Agent session. The integration follows
these explicit boundaries:
- Declared route validation:
The caller component issues a child call:
The host validates that
slot: "summarizer"exists in its static, operator-authorized route table. A model-generated slot name or ungranted target is refused immediately with a JSON-RPC error. - Translate input to an ACP prompt: The adapter formats the declared input into the ACP Agent's prompt or session work. It supplies bounded context and instructions, preserving any attachments or scratch directories authorized for that slot.
- ACP updates are observations, not terminal results:
During execution, the ACP Agent emits streaming notifications (text tokens, tool
calls, thought updates). These are streaming observations. If the caller component
declared an incoming progress channel, the host may forward updates; otherwise,
they serve as host diagnostics. They do not fulfill the pending
flow/call. - Contract validation of the final answer:
When the ACP Agent signals turn completion, the adapter extracts the final response,
validates that it satisfies the slot's contract (e.g., verifying
{ summary: string }), and returns the complete correlated result to the caller component: - Cancellation and failure ownership:
If the caller cancels or hits a deadline, the host sends
request/canceland the adapter terminates or cancels the ACP session (session/cancel). If the ACP Agent process crashes, disconnects, or emits malformed output, the adapter returns a settled JSON-RPC operational error. If side effects cannot be verified, the host records execution as uncertain rather than retrying automatically.
#Implement the invocation lifecycle
- Inspect Package/0: exactly one root
FLOW.<ext>entrypoint, its metadata, and any invocation contract. Code metadata lives in optionalFLOW.meta.json; Markdown metadata lives in frontmatter. Check the selected runtime, dependency requirements and supported channels. - Prepare the execution environment and grants before starting work. Supply only selected settings, attachments, scratch space and a finite deadline. Keep credentials with their responsible host implementation.
- Send one complete
flow/runrequest with a string request ID. Run/0 uses bounded LF-terminated UTF-8 JSON objects over full-duplex stdio. Keep the reader active while awaiting responses and serialize writes. Stderr carries diagnostics, not protocol frames. - Service
flow/callonly while its invocation owner is pending. Validate its declared slot, operation identity, input and any explicit channel transfer; resolve only an authorized implementation. Supply the callee's own context. - Return and validate complete
{ outcome, output }results. Declared domain refusals are normal results; operational failures use the JSON-RPC error envelope. Neither progress nor channel EOF establishes successful execution. - On cancellation, send
request/cancelwith the pending request's ID. Enforce deadlines and bounded termination even if the component ignores cancellation. Settle the complete owned subtree and resources; do not retry uncertain work automatically. - After a terminal response, drain stdout and await process exit. Accept success only with a valid correlated result, no pending owned requests, no trailing bytes or frames, successful cleanup and a zero exit status. A shutdown kill after a result is an execution failure.
Cancellation has this exact notification shape; it carries no id and receives
no response:
Run/0 specifies validation, error codes, identity, cancellation and completion in more detail. These duties do not prescribe Jig's review, persistence or sandbox implementation.
#Exercise both directions locally
This trusted-code exercise runs a caller and a greeter using Node 24, npm and Python 3.11+ on Linux or macOS. It uses the public, standard-library-only Run/0 test peer. The peer checks framing and process completion. It inherits the launching process's environment and does not contain descendants; run it with the clean environment below and only code you trust. It is not a production host library.
Create an empty directory and install the published SDK:
Save this caller as FLOW.mjs:
Declare its dependency in FLOW.meta.json:
Save this implementation as greeter/FLOW.mjs. Both packages use the installed
SDK in this local exercise:
Save the public peer's run0_peer.py in the exercise directory, then save this
as host.py. It serves one exact dependency call for these packages. A general
host additionally needs the other validation, authority, concurrency, channels
and lifecycle duties described above.
Run the exercise without ambient credentials:
The expected output is:
Change Hello, to Welcome, in the greeter and change the final expected message
in host.py. Run again: the caller is unchanged and receives the new result.
As a failure case, remove output from the greeter's return value. The SDK
rejects it; the host does not print a successful result. A component which emits
trailing stdout or exits nonzero after responding must also fail completion.
#Verify an implementation
Use the Run/0 conformance corpus and its README for executable component/host-peer checks. Start with ordinary invocation and slot calls, then test malformed frames, error responses, cancellation, pending work, nonzero exits and trailing output. Implement the channel extension when your host claims that support.
Protocol evidence does not establish containment. The host's threat model must cover filesystem and network authority, resource limits, credentials, descendant ownership and cleanup. Those controls belong to the host; a method declaration cannot grant them. Share implementation experience in GitHub Discussions.