Skip to content

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

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

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

Conversation

@Waishnav

@WaishnavWaishnav 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

coderabbitaiBot 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

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

FilenameOverview
src/local-agent-runtime-pool.tsAdds shared runtime acquisition, idle reaping, and shutdown handling; failed runs rely on the runtime implementation to report itself unusable.
src/local-agent-adapters.tsExtracts OpenCode into a reusable harness runtime, but its usability state does not reflect an unexpectedly failed server.
src/local-agent-runtime-registry.tsRoutes OpenCode through the pool while preserving one-shot behavior for other providers.
src/server.tsCreates the runtime registry and shuts it down after queued local-agent work drains.
src/local-agent-runtime-pool.test.tsCovers 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 threadsrc/local-agent-adapters.ts
@WaishnavWaishnav changed the title perf/subagent runtime poolperf(agents): pool shared harness runtimesAug 12, 2026
@Waishnav
Waishnavforce-pushed the perf/subagent-runtime-pool branch from 67e1f7e to e0d8d54CompareAugust 12, 2026 02:03
@Waishnav
Waishnavforce-pushed the perf/subagent-runtime-pool branch from a72edee to d256e42CompareAugust 12, 2026 02:18
@Waishnav

Copy link
Copy Markdown
OwnerAuthor

Closing this Sol stack PR in favor of the Luna-based implementation.

Sign up for freeto 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

@Waishnav