Skip to content

perf(agents): pool shared harness runtimes - #191

Open
Waishnav wants to merge 5 commits into
refactor/subagent-runtime-ownerfrom
perf/subagent-runtime-pool
Open

perf(agents): pool shared harness runtimes#191
Waishnav wants to merge 5 commits into
refactor/subagent-runtime-ownerfrom
perf/subagent-runtime-pool

Conversation

@Waishnav

@Waishnav Waishnav commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Provider adapters currently create expensive runtime resources for individual turns. This adds a small server-owned runtime registry and pool, then proves the sharing model with OpenCode: compatible agents reuse one OpenCode server while active work prevents eviction and idle runtimes are reclaimed.\n\nThe pool only owns live resources; logical agent identity and durable continuation state remain outside it. Provider-specific sharing policy stays behind each driver runtime key. Stacked on #190.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e14ef768-7356-444b-a4d3-c3de65387ee8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/subagent-runtime-pool

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

The PR introduces a shared, idle-reaped runtime pool for OpenCode subagents and wires its lifecycle into the server.

  • Reuses one OpenCode harness across compatible runs
  • Reclaims idle runtimes and closes them during server shutdown
  • Routes other providers through their existing one-shot adapters
  • Adds coverage for runtime reuse, eviction, and recreation

Confidence Score: 4/5

The OpenCode pooling path should be fixed before merging because an unexpectedly dead harness remains cached and can make every later turn fail.

The new pool supports replacement only when a runtime reports itself unusable, while the OpenCode implementation continues reporting usable after server or transport failures unless the pool explicitly closes it.

Files Needing Attention: src/local-agent-adapters.ts, src/local-agent-runtime-pool.ts

Important Files Changed

Filename Overview
src/local-agent-runtime-pool.ts Adds shared runtime acquisition, idle reaping, and shutdown handling; failed runs rely on the runtime implementation to report itself unusable.
src/local-agent-adapters.ts Extracts OpenCode into a reusable harness runtime, but its usability state does not reflect an unexpectedly failed server.
src/local-agent-runtime-registry.ts Routes OpenCode through the pool while preserving one-shot behavior for other providers.
src/server.ts Creates the runtime registry and shuts it down after queued local-agent work drains.
src/local-agent-runtime-pool.test.ts Covers reuse and idle eviction but not recovery after the underlying harness fails.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Request[Subagent request] --> Manager[LocalAgentManager]
  Manager --> Registry[LocalAgentRuntimeRegistry]
  Registry -->|OpenCode| Pool[HarnessRuntimePool]
  Registry -->|Other provider| Adapter[One-shot adapter]
  Pool -->|Acquire or create| Runtime[OpenCode harness runtime]
  Runtime --> Result[Provider result]
  Result --> Manager
  Reaper[Idle reaper] -->|Close idle runtime| Runtime
  Shutdown[Server shutdown] --> Manager
  Shutdown -->|After manager drains| Pool
Loading

Reviews (1): Last reviewed commit: "test(agents): cover runtime reuse and ev..." | Re-trigger Greptile

Comment thread src/local-agent-adapters.ts
@Waishnav Waishnav changed the title perf/subagent runtime pool perf(agents): pool shared harness runtimes Aug 12, 2026
@Waishnav
Waishnav force-pushed the perf/subagent-runtime-pool branch from 67e1f7e to e0d8d54 Compare August 12, 2026 02:03
@Waishnav
Waishnav force-pushed the perf/subagent-runtime-pool branch from a72edee to d256e42 Compare August 12, 2026 02:18
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