Skip to content

feat: add command_session tool for interactive long-running commands - #35293

Closed
OSN64 wants to merge 1 commit into
anomalyco:devfrom
OSN64:feature/command-session-tool
Closed

feat: add command_session tool for interactive long-running commands#35293
OSN64 wants to merge 1 commit into
anomalyco:devfrom
OSN64:feature/command-session-tool

Conversation

@OSN64

@OSN64OSN64 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

This PR implements a new `command_session` tool that allows the agent to run long-running interactive commands in the background, poll for output, send input, and terminate them.

Features

  • Start: Launch a command in a PTY-backed session
  • Poll: Get incremental output from a running session
  • Write: Send input to a running session
  • Interrupt: Send SIGINT to a session
  • Terminate: Kill a session
  • List: List all active sessions

Implementation

  • `packages/core/src/command-session.ts`: CommandSession service with PTY support
  • `packages/schema/src/command-event.ts`: Event schema for command lifecycle
  • `packages/opencode/src/tool/command-session.ts`: Tool definition with JSON Schema parameters
  • `packages/core/test/command-session/`: Integration tests

Configuration

  • Added localized `.opencode/opencode.jsonc` with provider config
  • Uses existing PTY infrastructure for terminal features (colors, cursor movement)

Notes

  • Timeout: 2 minutes default max runtime, 5 minutes inactivity timeout
  • Process group kill (kills entire process tree on terminate)
  • Requires `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true` env var

- CommandSession service with PTY support
- Tool with start/poll/write/interrupt/terminate/list operations
- Event schema for command lifecycle
- Integration tests
- Localized .opencode/opencode.jsonc config with providers
@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

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

Found a related PR! Here's what I discovered:

Related PR Found:

This earlier PR (#23794) should be reviewed to understand if there's existing implementation that could be reused, refactored, or if these serve different purposes despite similar PTY-based session management approaches.

@OSN64OSN64 closed this by deleting the head repository Jul 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@OSN64