Repository navigation
Report "Run in terminal" results back to the agent #27066
Closed
SebastianKlaiber
started this conversation in
Ideas
Replies: 1 comment
|
Closing as a duplicate of #19586, which tracks the same request. Please follow along there. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When an agent suggests a shell command, the code block's Run in terminal button types it into a drawer terminal. The agent never learns what happened. To continue, I have to copy the error from the terminal into the composer, or write "done" when it succeeded. This happens many times a day (auth logins, installs, migrations, failing tests the agent asked me to run), and it breaks the "click and keep going" flow the button promises.
The current design can't report on its own: the command is typed into an interactive shell, so the server never sees when it ends or its exit code. Subprocess polling runs once a second, so short commands are missed entirely.
Proposal
Each Run in terminal click opens its own terminal that runs the command through the user's shell (
$SHELL -i -c "<cmd>",-Commandfor PowerShell,/cfor cmd). The rc files still load, so PATH and aliases match a normal terminal. When the process exits, the server queues a notification on the thread, using the existing notification rows (the same ones background commands use):The message includes the exit code and the last ~80 lines of output (ANSI stripped, capped at 8 KB), so the agent can continue right away. If a turn is running, it waits until the turn ends (
queue_after_active).Details:
terminal.opengets an optionalcommandfield. Using it also requiresorchestration:operate, since it posts to the thread.Trade-offs
cdorexportfrom one run doesn't carry into the next. The alternative (keep typing into a shared shell and append an exit-code marker) keeps shell state, but needs per-shell handling ($?, fish$status,$LASTEXITCODE) and puts the marker into the visible command line.Status
I have a working implementation (contracts, server reporter service, web drawer, mobile terminal lifecycle, tests, and a short section in
docs/user/terminal.md) and tested it locally end to end. I'm happy to open a PR if the direction and scope sound right.All reactions