Repository navigation
serve: a host bash command's leftovers are the client's, never the model's - #271
Merged
Merged
Conversation
…del's A host `bash` RPC shared the session's job table, so `cmd &` was adopted as a model job. Its exit then woke the idle session: an unrequested, paid model turn whose input quoted the command and its output, even with exclude_from_context. The RPC result also carried model-facing bash_job instructions. - The host bash instance gets its own table (host_bash_jobs), which nothing takes notices from or wakes on. It survives a transcript switch and is stopped, unreported, when the session ends; ended entries are dropped at the next host command (BashJobs::forget_ended). - build_tools takes that table instead of a bool; a Bash that never detaches (has no bash_job) words an adoption for its client: "it runs until the session ends". Test: bash_jobs_serve_host.rs runs an excluded `(sleep 1; echo SECRET) &` on an idle session and checks no wake, no model call, no notice in the next prompt, then that a still-running leftover dies with the session (fails on main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes serve audit defect #10 (wrong output / privacy, from #253).
Problem
The host
bashRPC, which is the client's command and not the model's, shared the session's job table. So acmd &it ran was adopted as a model job. When that process exited, it woke the idle session. The wake was an unrequested, paid model turn whose input quoted the command and its output, even when the command was sent withexclude_from_context: true. The RPC result also told the client how to usebash_job, which is model-facing text.Decision: where host-bash leftovers live
They go in a table of their own,
host_bash_jobs, kept on the session:<background-jobs>carry.BashJobs::forget_ended), so the table stays bounded.bash_jobtool, so this wording is keyed on!detaches().build_toolsnow takesOption<&Arc<BashJobs>>, the client's table, in place of thebash_waits_for_exitbool. ARCHITECTURE.md ("One table per owner") documents all of this.Tests
New
crates/agent/tests/bash_jobs_serve_host.rs. On an idle session it runs(sleep 1; echo CLIENT-SECRET-OUTPUT) &withexclude_from_contextand checks:bash_jobtext;backgroundevent follows;It then checks that a still-running host leftover dies when the session ends. The test fails on main.
cargo fmt,clippy --all-targets -D warningsanddprint checkare clean. The agent + agent-core nextest suites passed in full, 3908/3908, on the stacked serve-jobs fixes.🤖 Generated with Claude Code
https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk