Repository navigation
Conversation
…ash program in auto mode
…ext program cannot start
…files, and reap the prompt before libfx/new
…cords that are not regular files
… session when a repair fails, and model the heal
# Conflicts: # tests/fuzz/targets.json
…on folders, and treat hard-linked records as damaged
…ebAssembly core builds
# Conflicts: # AGENTS.md
This branch has not been deployed
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.
Summary
experimental.bash_toolon, fx offers the model onebashtool in place of its file, search, web, and shell tools. Subagent, toolbox, and vision stay. Turn it on withfx config set experimental.bash_tool true, or for one run withfx ask --config experimental.bash_tool=true. With the setting off, every host offers the same tools as before.errexit,xtrace,posix, andexpand_aliasesare not carried: each program sets the first three for itself, and alias expansion is always on. The script runs after the user's startup definitions, so a name the program defined wins over one from.bashrc, and the save keeps only definitions that differ from the startup ones, so a later.bashrcedit still applies. fx hands the script to the shell as text, so child processes never load or save the state, and subshells never write it. The save calls every command throughbuiltinorcommand, so a program's ownmv()orwc()cannot change it. A program that sets its own EXIT trap keeps fx's save, and a program's ownIFSor shell options do not change it.exec. The last saved state stays, the call's result says so, and fx writes a debug trace line with the reason. The save leaves a small status record in the session folder, and fx reads it when the program's end is delivered, so the notice reaches the model even when the program ends withexit, is killed, or replaces itself withexec. If the next program cannot start, its failure result carries the notice instead.wait_morewaits for it again. One program runs at a time for each agent.dynamic_shell, because a saved function orPATHcan change what a command runs. For the same reason,automode reviews every bash program, including routine commands such asgit statusthat it runs without review for the shell tool. Configured allow rules and session approvals still match the exact command text, as they do for the shell tool. fx decides from the command alone whether a call is a program or a wait. A wait needs no command review inautomode, and it meets the sameterminalrules as shell'sinteract.fx mcp callworks from a bash program, as it does from the shell tool.fx ask, the TUI, ACP, and their subagents. A new conversation in the TUI (/new,/clear,/reset, resume, fork) or a new ACP session starts with a fresh bash state, and the TUI removes the bash folder when it quits. A subagent's bash state lasts one subagent run. A folder that a killed fx leaves behind is removed by the next bash session in the same temp folder once its owner process is gone. Each reset, including the end of a subagent run, and each sweep writes a debug trace line.libfx/newcancel and wait for a running prompt before it replaces the session. Without it, a host that sendslibfx/newwhile a prompt runs could free this change's bash state under the prompt, as it already can free the session runtime onmain. Merge Reap the running prompt before libfx/new replaces the session #2282 first.src/core/bash_session/keeps the saved state. It imports only the standard library, and other code reaches it only throughbash_session.zig, whichscripts/check-bash-session-boundary.shchecks in CI.after_startup: shell text that the command's own shell runs after the user's startup definitions and before the command, on both the startup-snapshot path and the full-startup path. Only the bash tool sets it. Every other caller passes an empty text, and its scripts and arguments stay byte-identical.shell_resolver.bashToolEnvironment. Shell and bash hand off their results throughtooling/managed_delivery.zigandSnapshot.failed(). The command limit, the wait time,wait_more, and the variables fx adds to each program come from their owners' constants.tests/tla/bash_tool/ResultStore.tlamodels the session: one program at a time,wait_more, a saved state that is never left half written, a state over the size cap that is never dropped without a notice, and session files a program damaged that fx heals before the next program, whose result says the state was lost. CI now runs its checker with the other models on every pull request.bash_call_textfuzzes the bash tool's argument decoder.Known limits
unsetcomes back from the startup files in the next program.Sample
With the setting on,
fx ask --json --config experimental.bash_tool=trueoffers the modelbash,toolbox, andvision. Two calls from a run of the built binary, then the result text of their programs:A program that runs past 30 seconds, then the wait:
The notice for a state over the size cap:
Architecture
Before:
After:
flowchart LR model[Model] --> select{experimental.bash_tool} select -- off --> set[builtin_tools.advertisement_set] select -- on --> bash_set[builtins/bash_tools.zig: bash, subagent, toolbox, vision] set --> admission[tooling/tool_admission.zig] bash_set --> admission admission -- bash host: start folder --> bash[tools/bash/bash.zig] admission --> shell[tools/shell/shell.zig] env[terminal/shell_resolver.zig bashToolEnvironment] --> admission env --> bash bash --> session[core/bash_session: folder, load and save script, program id, start folder] bash --> runtime[execution/managed_execution.zig] shell --> runtime runtime -- after_startup --> runner[execution/command_runner.zig and terminal/shell_resolver.zig] bash --> delivery[tooling/managed_delivery.zig] shell --> delivery bash --> bridge[mcp_host/mcp_call_bridge.zig] shell --> bridgeShip check
tests/tla/acp/,agent_runtime/,agents_menu/,auth/,managed_execution/,mcp_host/,saved_turn/,subagent/,terminal/, andtoolbox/describe files this change touches, and none of them changes. In those files the change picks the tool set, keeps and resets each agent's bash state, passes the bash start folder to admission, lets an inferredactionreplace one the model sent, moves shell's delivery handoff into a shared helper without changing it, makeslibfx/newreap a running prompt before it replaces the session, carries the empty-by-defaultafter_startuptext to the runner, has the snapshot capture pass an empty one, and adds a list of the bridge's variable names. The modeled behavior stays the same: permission modes and speed, the empty-reply nudge, the agent list, login refresh, managed command delivery, the MCP host, message order at step boundaries, steer queues, the startup snapshot owner and hosted terminals, and the toolbox menu. The setting is read once at startup, so the toolbox model's rule that a session's tools never change still holds.bash_call_text,request_wrapper_text,session_title,switch_order,agents_menu_selection,subagent_task_line,trace_record_text,trace_review_records, andsnapshot_alias_lines, each ran clean for 60 seconds, andzig build fuzzreplays every target. The other 13 are reached only through imports, so they are left to the nightly fuzz run. The Fuzz workflow on this branch passes.d3399becc9, this change adds 57,648 bytes to the stripped Linux x86_64 ReleaseSafe binary, so the binary-size check shows its informational note (52,429 bytes). Most of it is the two new bash files. In hyperfine runs of 200 and 300 onmain170f50e45d,fx sessions --jsonand startup took the same time with and without this change (1.5 to 1.7 ms against 1.5 to 1.6 ms, and 505 µs against 558 µs).CAP_DAC_OVERRIDE). CI's runner is not root, so they run there, and they pass in a sandbox with those capabilities dropped.kill(pid, 0)in the dead-folder sweep delivers no signal and only asks whether the process exists. The Thread Sanitizer run on this branch reports 6 warnings, and all 6 matchmain's latest nightly run. One of them, the thread leak created atshell_snapshot.zig:692, passes throughmanaged_execution.zig, which this change edits only to add the sharedfailed(), two names, and theafter_startupfield;mainhas the same leak at the same site. No warning namesbash_session.zigorbash.zig.