Skip to content

fix(agent): frame local tool output as data by default - #5

Draft
Bonchaloo wants to merge 2 commits into
fix/untrusted-tool-result-framingfrom
fix/default-untrusted-tool-results
Draft

Bonchaloo wants to merge 2 commits into
fix/untrusted-tool-result-framingfrom
fix/default-untrusted-tool-results

Conversation

@Bonchaloo

@Bonchaloo Bonchaloo commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Issue

read_file, search_files, terminal, and execute_code can surface text from an attacker-authored repository, web page, package, or process, yet the model-facing tool message was unframed. A synthetic directive canary passed straight through make_tool_result_message on the #2 branch.

This is a stacked draft based on #2 (fix/untrusted-tool-result-framing, dc03571e228c1a0205b262b2b406e40578ba9834). Review and merge #2 first, then rebase this branch onto the resulting main revision before considering this PR.

Change

  • Treat nonempty tool text as untrusted data by default. The explicit instruction-tool allowlist is skill_view (loads the skill's instructions) and clarify (returns the user's direct answer).
  • Preserve the existing multimodal list shape and image parts; frame text parts and bare string parts. Encode unknown tool names safely in the frame's source attribute.
  • Keep raw results available to progress and completion callbacks; only the model-facing message is framed.

Verification

  • Offline canary on fix(agent): frame all external tool text safely #2: synthetic read_file, search_files, terminal, and execute_code outputs remained raw. On this branch, all four carried the provenance warning and one frame; skill_view stayed unwrapped. No command or tool handler ran in that canary.
  • A mocked read_file dispatch test verified the progress and completion callbacks received the original payload, while the model-facing message was framed. The blocked write_file result test was updated to parse JSON within its new frame. After first CI, the corrupted-arguments repair test was updated to assert its factual marker remains visible inside the frame for read_file.
  • pytest tests/agent/test_tool_dispatch_helpers.py tests/run_agent/test_tool_call_guardrail_runtime.py tests/run_agent/test_tool_call_args_sanitizer.py tests/run_agent/test_run_agent.py::TestConcurrentToolExecution::test_sequential_blocked_tool_skips_checkpoints_and_callbacks -q: 59 passed using the isolated Python 3.13 test interpreter with read-only Python 3.12 site-packages for missing dependencies. Neither environment was modified.
  • Ruff, Python compile, and git diff --check passed.

Review limits

No model compliance, live command, external fetch, deploy, or installed Hermes behavior was tested. This central builder covers Hermes' primary sequential and concurrent tool executor. Other synthetic/projected tool messages created outside make_tool_result_message are separate paths and were not changed here. The two allowlisted tools intentionally pass their content through as instructions; review that trust decision before merge. The fork's existing contributor-attribution and model-name CI failures are tracked in the local assessment; required checks must be green before merge.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🔎 Lint report: fix/default-untrusted-tool-results vs origin/fix/untrusted-tool-result-framing

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 12433 on HEAD, 12431 on base (🆕 +2)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 6744 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant