Repository navigation
Conversation
4 tasks done
rominf
force-pushed
the
fix/chat-paste-safe-model-values
branch
from
November 17, 2026 13:10
602bdf2 to
0a5d61d
Compare
| .iter() | ||
| .map(|args| format_structured_tool_call("rocm", args)) | ||
| .collect::<Vec<_>>(); | ||
| assert_eq!(lines.len(), 3, "{text}"); |
Collaborator
Author
There was a problem hiding this comment.
This line is an assertion message inside the unit test the_planned_args_are_the_tool_call_lines_of_the_text (#[cfg(test)], freeform_planner.rs): {text} is the plan the test itself builds from the fixed request serve qwen3.5 with vllm, and it is printed only when the assertion fails under cargo test. Nothing reaches a log from it and no outside input flows into it, so there is nothing to clean here; the code still holds as of 0786864.
Contributor
Security scan found no critical or high findings on lines changed by this pull request1 medium, low, or unrated finding(s) are not listed; the scan run has them. View the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
rominf
force-pushed
the
fix/chat-paste-safe-model-values
branch
from
November 17, 2026 15:52
0a5d61d to
0786864
Compare
…line `rocm chat` prints text a model chose: its reply, tool output, error messages that quote either, and command lines built from the values in its tool calls. Two gaps let that text decide what the user sees or runs. Prose was printed verbatim, so a reply could hide part of a line, retitle the window, write the clipboard or move the cursor. `rocm_core::terminal::sanitize_terminal_text` now removes escape sequences whole in their 7-bit and 8-bit forms, drops invisible characters, keeps line breaks and shows concealed text instead of dropping it. A string sequence left unterminated ends at its own line, so the CLI's own lines after it always survive. The shared terminal grammar also accepts the 8-bit string terminator, and the check that decides whether a log line may be quoted into a printed command refuses the same invisible characters. The reply, the model name, each tool result and the follow-up answer are sanitized before they are composed with the CLI's lines, the whole rendered turn goes through it once more, and so does the error report every `rocm` command prints. The values refused in tool arguments widen from controls and format characters to Unicode's whole default-ignorable set. The joiners and presentation selectors an emoji is spelled with stay allowed: one directly after a drawn character, and a joiner directly after such a selector, so an emoji folder name still works. Values the model chose refuse any invisible character. GGUF architecture names and listed file names are held to the same character set. Command lines shown for the user to approve or paste are POSIX-quoted, which Windows shells read differently: PowerShell and cmd.exe give quotes and `& | < > ^ % " !` meaning inside single quotes. A value the model chose is now refused if it holds one of those or a typographic single quote, with a message naming the character and the `rocm` command the user can run with it themselves, and saying that nothing was changed and nothing was offered to paste for that call. This applies to calls in the provider's reply, the plan `natural_language_plan` returns for a model-written request (a result whose planned argvs cannot be read is refused), the dashboard agent's tool calls (through a new `execute_model_call` on the tool executor) and the provider planner. Each call is checked before it runs, and a plan before it is shown; a read-only check earlier in the same reply may already have run. Calls the CLI builds from the user's own request, and the dashboard's slash commands, are not affected. A `serve` the model requests may only use long options `rocm serve` has, must name exactly one model, and names its model and option values only with letters, digits and `. _ - / : @ + \`, not starting with `-`. New e2e scenarios chat-20 to chat-22 cover the printed reply, the refused value and the refused plan, and runtime-lifecycle-32 covers the cleaned error report, all on the mock lane. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
rominf
force-pushed
the
fix/chat-paste-safe-model-values
branch
from
November 17, 2026 16:03
0786864 to
5652aaf
Compare
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.
Problem
rocm chatprints text a model chose: its reply, tool output, error messages that quote either, and command lines built from the values in its tool calls (theadvanced manual command:line, the approval card, the request plan'stool_call:lines). Two gaps let that text decide what the user sees or runs:sh, bash and WSL. PowerShell ends a single-quoted string at an embedded quote, andcmd.exegives single quotes no meaning at all, so& | < > ^ %,"and (under delayed expansion)!keep their meaning inside them. A value the model chose could therefore add a command to a line the user pastes on Windows.Fix
Tool-call values. Every string a tool call carries, from the model or built from what the user typed, is refused if it holds something a terminal would not show as it is: a control or escape sequence, a format character such as a bidi override, a line separator, or another default-ignorable character such as a tag character. The exception is the characters an emoji is spelled with: a single zero-width joiner or non-joiner, or emoji or text presentation selector, directly after a drawn character, and a joiner directly after such a selector (
❤️,👩💻,🏳️🌈).Values the model chose for a command line the CLI shows (the approval card, the
advanced manual command:line, the install preview, and the plan'stool_call:lines) are held to more:', typographic single quotes,& | < > ^ % " !);rocm servemay only use long optionsrocm servehas, must name exactly one model, and may only use. _ - / : @ + \, letters and digits in its values (at most 256, not starting with-);Calls the CLI builds from the user's own request are not held to these: a folder in a request the CLI recognises itself (
install therock into <folder>), or in a dashboard slash command, is rendered as typed. A folder the user names in other words reaches the CLI through the model's call and is held to them like any value the model chose.Each call is checked before it runs, and a plan before it is shown; a read-only check earlier in the same reply may already have run. The refusal names the value and the command to run with it (only words that are real
rocmsubcommands, so the command named exists), and says nothing was changed and no command was offered to paste for that call. Inrocm chat --promptnothing from the turn reaches stdout.Plans. The plan
natural_language_planreturns for a request the model wrote is checked the same way before it is shown, because the planner turns words of that request into the values on itstool_call:lines. The tool reports those argvs beside the text, and a result whose argvs cannot be read is refused. The planner's own<model>placeholder passes only as the model of arocm serve.Terminal output. Prose that cannot be refused (the reply, the model name the server reports, tool results) is printed by
rocm chat --promptwith escape sequences (CSI, OSC, DCS, SOS, PM, APC, and their 8-bit forms) and invisible characters removed and line breaks kept, so concealed text is shown. A sequence left unterminated ends at its own line, so the lines printed after it, including the CLI's own, survive. The error report everyrocmcommand prints goes through the same cleaning. GGUF architecture names and listed file names are held to the same character set.The dashboard agent's tool calls go through a new required
RocmToolExecutor::execute_model_call, so they get the model-chosen rules; dashboard slash commands keepexecute.The assistant's built-in guidance (
skills/rocm-cli-assistant/SKILL.md, compiled into the chat system prompt) states these rules, so the model hands such a value back to the user instead of rewriting it. The ASCII-output contract's exemption note forterminal.rsis reworded for the wider set of characters that module names.Tests
chat-20(@id:chat-cli-reply-escapes-stripped): escapes are removed, concealed text is shown, and the line after an unterminated sequence is kept.chat-21(@id:chat-assistant-value-unsafe-to-paste-refused): aninstall_sdkfolder with&is refused, nothing reaches stdout, and the user's ownrocm install sdk --dry-runinto the same folder is accepted and names it as one argument, which shows the remediation the refusal names works.chat-22(@id:chat-assistant-plan-unsafe-to-paste-refused): a plan for the assistant's request into that folder is refused.runtime-lifecycle-32(@id:runtime-lifecycle-error-report-carries-no-escape):rocm runtimes activatewith a runtime name carrying escape sequences fails, its error report names the runtime with the sequences removed and holds no control character, and no runtime is active.rocm-core'sterminal.rs, with exact-output and property tests; the paste-unsafe set, the serve rules, the placeholder slot, the plan check (including unreadable argvs and an unsafe plan that is not the last) andplanned_argspinned to the plan'stool_call:lines intool_policy.rsandfreeform_planner.rs; model-versus-user origin and check-before-run inproviders.rs(the chat turn against a scripted local model, which also checks no folder, server or runtime was added) anddash_seam.rs(refused and safe model calls through the real executor); the error report, which also passes withRUST_BACKTRACE=1.runtime-lifecycle-32, treating every dashboard model call's result as a plan fails the safe-call seam test, and dropping the selector-then-joiner rule fails the emoji rows.Verified locally (Linux)
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo xtask check-architecture-doc,cargo xtask check-crate-edges,cargo xtask check-module-size.cargo test --workspace --all-targets --no-fail-fast: all pass except tests in code this change does not touch that fail on this host for its own reasons:service_control::tests::stop_of_a_container_engine_is_unconfirmed_when_the_engine_stop_fails(dockerhere is a podman shim) and twobuild_scripttests that create a scratch git commit under this host's signing configuration.cargo xtask e2eforchat-20..chat-22,therock-next-15and the runtime-lifecycle scenarios: all pass exceptruntime-lifecycle-12(@requires-gpu @requires-engine:vllm), which this host ran against a Lemonade service; that scenario's own comment notes it cannot pass there, and this change touches no runtime activation or service restart code.Not verified
cmd.exe.cargo xtask smoke.Behaviour change
rocm chat --promptoutput and everyrocmerror report no longer contain terminal escape sequences or invisible characters; concealed text is shown, and a lone carriage return or line/paragraph separator becomes a line break.', a typographic single quote,& | < > ^ % " !, or an invisible character. The request is refused with a message telling the user to run the command with that value themselves.serveis limited to the options and character set above.rocm chat --help,docs/llm-tool-use.md,docs/testing.mdanddocs/manual-testing.md.Follow-ups
strip_terminal_control_sequences, used for the provider planner's failure note, still uses a narrower predicate than the sanitizer; the note is sanitized again when chat prints it.rocm servehas, including--api-keyand--engine-env; the approval card shows them.rocm_commandis held to the paste rule though no command line is shown for it.serve, a model-chosen value may hold a space:cmd.exethen splits it into separate arguments of the samerocmcommand when pasted, though nothing in it can run as a command of its own (stated indocs/llm-tool-use.md).args[0]isserve, not toremote serve.tests/e2e-cucumber/expectations.tomlfor the fixed ticket ID and removed/narrowed any now-stale xfail rows.docs/architecture.md(the clap declaration incli.rsand the dispatch wiring inmain.rs/lib.rsare expected, not a violation)..rsfile underxtask/srcortests/e2e-cucumber),docs/architecture.mdhas the matching entry (cargo xtask check-architecture-docfails otherwise), and the prose of any entry whose file changed role still describes it, which the check cannot verify.e2ejob (for example by a tag) is justified as a deletion (AGENTS.md §8).