Recipes

Opt-in Deep Agents runtime integration for Harness Engine with durable sessions and replay

Discovered from README cross-links · yesterday

Software & DevOpsWork & Operations

Wired a Deep Agents runtime into Harness Engine behind a flag, with replay

What they did

The author integrated the existing Deep Agents runtime into Harness Engine as an opt-in extension, reusing the native runtime behind a DeepAgentsAdapter with typed events before SSE encoding and explicit completed, paused and cancelled outcomes. They added durable execution ownership so a chat refresh before the first assistant token recovers the admitted run, rebuilds the assistant turn and subscribes to replay instead of resubmitting the prompt. Pending interrupts are persisted and require the exact saved form or tool approval on resume, with deduplicated approval retries and fenced ambiguous dispatches. Runtime caches are scoped to caller credentials, captured user context and execution version, and native thread IDs are preserved during adoption and rollback. A MongoDB producer fence is shared between Engine and the upgraded compatibility service, cancellation is drained before admitting another turn, and immutable execution versions are prepared before publishing the agent's version pointer. The UI gained capability-driven Builder controls and bounded Advanced panels, plus browser SSE subscription recovery with precise subframe cursors. Slack approval payloads now carry interrupt identity and permitted decisions. Rollout is gated by HARNESS_ENGINE_DEEP_AGENTS_ENABLED with a separate default-off adoption flag and an optional Compose overlay. Validation included live E2E over SSH on an isolated deployment with two Engine replicas, Chromium SSO tests, and large pytest and Jest suites, with Codex used for implementation, tests and documentation.

How it went

16 API E2E checks and 6 Chromium checks passed, along with 70 Harness Engine and 770 Dynamic Agents pytest cases, 9,326 UI Jest tests and 26 Slack HITL tests. A live owner run survived two subscriber disconnects and completed in 302.798 seconds with exactly one wait invocation, and its transcript replayed after the UI container was replaced. A legacy conversation was adopted with its original checkpoint ID. Full repository CI was still pending at posting.

Worth knowing

The integration is experimental and opt-in, and existing-context adoption is disabled by default. A fresh signed-in browser refresh on the main site was not verified because the user's Mac was locked. FinOps/Bedrock/AWS workloads, live external MCP calls, Slack/Webex delivery and TOME in-app execution were not qualified. External sandbox workers, cross-harness delegation and automatic takeover after a producer crash remain out of scope. The diff exceeds 500 handwritten lines and includes a 2,454-line generated uv.lock.

Wiring

Deep Agents runs behind a DeepAgentsAdapter that wraps the native LangGraph runtime, keeping existing checkpoints, tools, middleware, skills, files and subagents. Events are typed before SSE encoding and flow through BFF routing to the browser, which reconnects using subframe cursors. State ownership sits in MongoDB with a producer fence shared between Engine and the upgraded compatibility service; both producers must be upgraded before migration, and active runs stopped before handoff. Execution versions are immutable and prepared before the agent version pointer is published, with saves serialized against permission reconciliation. Runtime caches are keyed by caller credentials, user context and execution version. CAS/OpenFGA checks and delegated caller identity are retained, and attachment references are staged and authorized per namespace. Deployment uses an optional compose.deep-agents.yaml overlay that upgrades both producers and shares attachment storage, while canonical default profiles stay unchanged.

Try it yourself

Read the Harness Engine and Deep Agents integration in this repo. Add an opt-in DeepAgentsAdapter behind HARNESS_ENGINE_DEEP_AGENTS_ENABLED that reuses the native runtime, emits typed events before SSE encoding, and reports explicit completed, paused and cancelled outcomes. Persist pending interrupts and require the exact saved form or tool approval on resume, deduplicating retries. Make a chat refresh before the first assistant token recover the admitted run by rebuilding the assistant turn and subscribing to replay rather than resubmitting the prompt. Preserve native thread IDs during adoption and rollback, share a MongoDB producer fence between Engine and the compatibility service, and prepare immutable execution versions before publishing the version pointer. Add browser SSE recovery with subframe cursors, capability-driven Builder controls, and tests covering restart continuity, pause/resume, cancellation, reconnect and version pinning.

Source

Tools in this stack