Skip to content

perf(headless-runner): reuse a turn's tools and memory across its steps - #7417

Merged
reachjalil merged 1 commit into
devfrom
perf/runner-steps-keep-their-tools
Nov 14, 2026
Merged

reachjalil merged 1 commit into
devfrom
perf/runner-steps-keep-their-tools

Conversation

@reachjalil

Copy link
Copy Markdown
Member

What is this about?

Making each step of a headless runner turn start sooner: a step-mode turn now lists the OpenWork MCP tools and reads memory/ once, not before every model call.

What problem does it solve?

Every step reconnected to OpenWork MCP, listed the tools and re-read memory before calling the model. In a hosted runner's turn logs that took about a second per step at the median, and most steps never call an MCP tool. A memory write mid-turn also changed the next step's system prompt, which missed the prompt cache.

What was the situation before?

A turn run in one go connected and read memory once. A step-mode turn, which is every new turn, did both on every step.

How is this implemented?

  • runner.ts: the run keeps the tool list (per MCP token) and the memory files its first step read; later steps reuse them.
  • laterStepTools: a later step connects only when the model calls an MCP tool, starting as the model begins writing the call, and closes when the step ends. Nothing stays open between steps.
  • If that connection fails after three tries, the step's MCP calls answer "not made, try again" and the next step reconnects. The turn used to end mcp_unavailable there; the first step still does.
  • A restart or a fresh token lists the tools again.

What else changed?

  • The README, OWNER-CELLS.md and memory.ts comments describe the once-per-run reads.

Release note

Multi-step answers from Workbot, Slack replies and Automations start each step sooner.

Evidence

  • scripts/steps.test.ts — before: a connection and a memory read before every step's model call; after: one tool listing and one memory read per run, and a later connection only for an MCP call.
  • scripts/steps.test.ts — before: an unreachable MCP server on a later step ended the turn; after: the call says it was not made and succeeds on the next step.

A turn that runs step by step connected to OpenWork MCP, listed the tools
and read memory/ again before every model call. A turn run in one go does
each once.

- The run's first step lists the tools and reads memory; later steps show
  the model the same list and memory, so every request starts the same and
  no later step waits on either before its model call.
- A later step connects only when the model calls an MCP tool, starting
  as soon as the model begins writing the call, and closes when the step
  ends. Nothing stays open between steps.
- When that connection can't be made, the step's MCP calls say they were
  not made and the next step connects again. The turn no longer ends
  mcp_unavailable there; the first step still does.
- A restart or a fresh MCP token lists the tools again.

Signed-off-by: Jalil <reachjalil@gmail.com>
@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Nov 14, 2026 1:01am UTC
openwork-den Skipped Skipped Nov 14, 2026 1:01am UTC
openwork-landing Skipped Skipped v0 Nov 14, 2026 1:01am UTC

Request Review

@reachjalil
reachjalil merged commit c71d566 into dev Nov 14, 2026
19 checks passed

This branch was previously deployed

3 inactive deployments
Preview – openwork-den — bfae73aa Deployed Nov 14, 2026 by vercel[bot]
Preview – openwork-landing — bfae73aa Deployed Nov 14, 2026 by vercel[bot]
Preview – openwork-app — bfae73aa Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant