Use @agent-harness-experimental/workflow when you want a createAgentSession() session to live inside
Workflow DevKit: survive slice timeouts, pause for approvals or external tool
results, and resume on the same sandbox session.
Usage
import { createAgentSession, resumeAgentSession } from "agent-harness-experimental";import { codex } from "@agent-harness-experimental/adapter-codex";import { orchestrateAgentWorkflow, type AgentWorkflowRuntimeContext,} from "@agent-harness-experimental/workflow";async function createAgent(ctx: AgentWorkflowRuntimeContext) { "use step"; const createSession = ctx.resumeState ? resumeAgentSession : createAgentSession; return createSession({ ...ctx, adapter: codex({}), });}export async function chatWorkflow(input: { prompt: string; }) { "use workflow"; return orchestrateAgentWorkflow({ input, createAgent, });}
orchestrateAgentWorkflow() owns the slice loop, timeout handling, host
continuations, and final workflow finish event. Pass ctx straight into
createAgentSession() / resumeAgentSession() so the helper can manage:
the session id
resume mode
workflow resume state
If your workflow input includes sessionId, the helper will use it. If not, it
will create one before the first slice.
What The Package Handles
Runs the agent one workflow slice at a time.
Calls agent.close("detach") when the slice budget expires.
Restarts the next slice with the exported resume state.
Waits on a workflow hook when the agent needs approval or an external tool result.
Writes the final workflow-level finish chunk.
Resuming A Blocked Workflow
If the agent is waiting on approvals or tool results, resume it from your app by
submitting a continuation and waking the workflow run: