Files
SivanCola 93409eec04 fix(tools): normalize envelopes and use patched Go
Problem: A redundant arguments envelope makes usable tool calls fail required
field validation and can cause repeated model retries. The current CI security
scan also reports GO-2026-6809 in the pinned Go 1.26.9 standard library.

Root cause: Scheduling, policy checks, execution, and history had no shared
representation of effective arguments inside a schema-invalid wrapper. The
root and Desktop modules still selected the affected Go patch release.

Fix: Unwrap one unambiguous envelope only after full target-schema validation.
Use effective arguments for host execution, evidence, decision barriers, and
surface actions while retaining the original provider call. Select Go 1.26.10
for both modules so CI and packaged Desktop use the patched standard library.
Style the compatibility notice and original-input disclosure like adjacent
tool metadata, with a visible expand marker and keyboard focus outline.

Verification: The envelope regression suites, provider history, permission,
proxy, and interactive surface tests passed. With Go 1.26.10, govulncheck ./...
reported zero reachable vulnerabilities and go vet ./... passed. Frontend type
and interaction checks passed on the rebased PR. The final card style passed
frontend type checking, 16 relevant UI tests, make check, and local browser
inspection in light and dark themes with its disclosure closed and open.
2026-10-21 11:56:58 +08:00

32 lines
926 B
Go

package agent
import (
"encoding/json"
"reasonix/internal/contract/provider"
"reasonix/internal/contract/tool"
)
func (a *Agent) prepareCallArguments(call provider.ToolCall) provider.ToolCall {
// Recompute from original bytes; persisted metadata never authorizes input.
call.ArgumentNormalization = nil
target, _, ambiguous := a.svc.tools.ResolveCall(call.Name)
if target == nil || len(ambiguous) != 0 {
return call
}
if args, changed := tool.PrepareArguments(target, json.RawMessage(call.Arguments)); changed {
call.ArgumentNormalization = &provider.ArgumentNormalization{
Reason: provider.ArgumentEnvelopeUnwrapped, Original: call.Arguments, Effective: string(args),
}
}
return call
}
func (a *Agent) prepareCallBatch(calls []provider.ToolCall) []provider.ToolCall {
out := append([]provider.ToolCall(nil), calls...)
for i := range out {
out[i] = a.prepareCallArguments(out[i])
}
return out
}