Skip to content

feat(core): add interactive process tool family - #49985

Closed
yurial wants to merge 1 commit into
anomalyco:devfrom
yurial:interactive-tool
Closed

yurial wants to merge 1 commit into
anomalyco:devfrom
yurial:interactive-tool

Conversation

@yurial

@yurial yurial commented Sep 19, 2026

Copy link
Copy Markdown

Issue for this PR

Closes # (no tracking issue — the spec below is the source of truth for this feature)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an interactive tool family — interactive_start, interactive_write, interactive_wait, interactive_cancel — for driving long-lived child processes (gdb, REPLs, installers) across provider turns. Until now the only process tool was a one-shot exec, so any task that needs a conversation with a running process (send a command, read output, decide, send another) had to be crammed into a single blocking call with a hard timeout.

How it works, briefly:

  • interactive_start launches the child under a PTY and returns a job ID immediately; output is written to a per-job spool file with a monotonically advancing delivery cursor, so each interactive_wait picks up where the previous read stopped.
  • Waiting uses quiescence-based settle: instead of a fixed sleep, the tool waits for a configurable quiet window on output, and feeds fresh output back to the model automatically while the process keeps talking, so a chatty program doesn't starve the turn.
  • Each job has exchange (turn) and lifetime budgets enforced by a governor, plus a start timeout; on breach, jobs are terminated rather than leaking.
  • An orphan-process ledger tracks jobs whose owning session died; a startup sweep reaps leftovers from previous runs, and session interruption kills claimed jobs, closing the claim/kill races.
  • Job state lives in a Location-scoped store, consistent with the other location-scoped services. The tools are permission-gated, and exposure is controlled by interactive.* config keys.
  • The family is registered in the V2 tool registry and bridged into the V1 session path so both session implementations can use it.

The change is spec-first: specs/tool-interactive.md (included in this PR) defines the tool contract, budgeting, and lifecycle rules that the implementation follows.

How did you verify your code works?

  • packages/core: bun test test/tool-interactive.test.ts test/tool-interactive-store.test.ts test/tool-interactive-spool.test.ts test/tool-interactive-governor.test.ts test/tool-interactive-ledger.test.ts test/session-execution-interactive.test.ts — 48 pass, 0 fail (covers tool behavior against a real fixture process, spool/cursor semantics, settle/governor budgets, orphan ledger + startup sweep, job store, and the V2 session execution wiring).
  • packages/core: bun typecheck — clean.
  • packages/opencode: bun test test/tool/interactive.test.ts — 4 pass, 0 fail (V1 bridge and registry wiring).
  • Tests run from the package directories, not the repo root.

Screenshots / recordings

Not a UI change — no screenshots.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Interactive tool family (interactive_start/write/wait/cancel) for driving
long-lived child processes (gdb, REPLs, installers) across provider turns:
PTY jobs with per-job spool files and delivery cursor, quiescence-based
settle with automatic output feeding, per-job exchange and lifetime budgets,
orphan-process ledger with startup sweep, Location-scoped job store,
permission gating, config keys (interactive.*), V2 registration and V1
session bridge, spec (specs/tool-interactive.md) and tests.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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.

2 participants