Repository navigation
spark-server: tool-call guard (atlas-tool-guard crate, --tool-guard, default off; ported from Enntity) - #227
Conversation
|
First run on a CUDA host (reiner job 915): the CUDA build passes and |
|
Pair checks vs parent (binary 4f938181, two GB10s, rc16 resident profile): with the guard off (default), greedy C1 equals #198's serial references 8/8. With |
|
Unit tests fixed at |
|
Re-check on |
|
Known issue at this head: |
|
Guard confirmed working on the live pair (stack head with this PR, |
a1dab65 to
853445e
Compare
c643812 to
a9770b5
Compare
|
@data-angel a question from gating this port; the behaviour is the same in your |
853445e to
31a9803
Compare
a9770b5 to
c681361
Compare
…rn guard (port of fa5331b et seq.) Bounded CPU-only screening of completed tool-call arguments: operation- scoped destination and payload checks (metadata access, credential transfer, blocked hosts, size cap), normalized for common host/command forms. Wired at the streaming handlers (start/delta/fragment/end), the pending-bytes ceiling on content tokens, the done-path incomplete-call check, and the blocking choice path (refusal + content_filter finish). Operator-only switch --tool-guard on|off (default on, output-neutral for well-formed calls), --tool-guard- {allow,deny}-host and --tool-guard-max-bytes. Upstream adaptations: ir::response::Choice has no guard_stop field here, so the blocked choice is marked by finish_reason == ContentFilter alone; StreamDelta:: Finish likewise. Files >500 LoC (tool_handlers, handle_token) are on the CI allow-list.
The guard can refuse well-formed calls that match its exfiltration patterns, so it is not output-neutral and stays off by default here; the help text notes that SparkQwen enables it.
The tool-guard tests declare three tools (get_weather, get_url, write_document) in their own request(); defs built from the parent fixture's request() carried only get_weather, so five tests died on 'Unknown tool' validation before the guard was exercised. Pass the request through like Enntity's stream_for_request. Fixture fix, not a wiring fix.
… caps The enabled-guard flush/drop check was inserted between the F11 dedup and the name-run cap, so a call tripping the name-run cap flushed its buffered deltas instead of dropping them (tool_guard_does_not_release_calls_stopped_by_loop_limits). Move it after both cap checks, matching Enntity's ordering.
handle_tool_call_delta flushed the buffered start+args straight to the stream even with the guard enabled, releasing call bytes before the completed-arguments inspection ran (tool_guard_checks_both_native_formats_before_any_tool_bytes). Gate the flush on the guard being off, as in Enntity's version.
31a9803 to
a068da0
Compare
c681361 to
c156541
Compare
Stack: main ← #198 ← #223 ← #224 ← #226 ← this.
Summary
crates/atlas-tool-guard, copied verbatim from Enntity/atlas (AGPL-3.0,fa5331b2+ fixups41d5fd28,1cff5cb2,acc404e1,d0cead14). It scans streamed and blocking tool calls for destination/exfiltration patterns (hosts, scp/rsync remotes) and caps pending tool bytes. A refused call finishes withcontent_filterand a refusal message.--tool-guard on|off(default off: when on it refuses some well-formed calls, so it isn't output-neutral; SparkQwen ships it on), plus--tool-guard-allow-host,--tool-guard-deny-hostand--tool-guard-max-bytes.guard_stop;finish_reason == ContentFilter+ REFUSAL is the marker.Test plan (vs parent #226)
cargo test -p atlas-tool-guardtool_security/tool_guardtests, guard off: greedy C1 == serial refs; guard on: tool probe + greedy C1Tracking: #220.
Generated with Devin