diff --git a/agent/finding_workflow.go b/agent/finding_workflow.go index 5362a26..a44a689 100644 --- a/agent/finding_workflow.go +++ b/agent/finding_workflow.go @@ -87,6 +87,33 @@ func trafficCaptureOffToolNote(toolName string, captureOff bool) string { } } +// Automatic traffic binding off is a DIFFERENT switch from capture off: capture +// can be on while binding is off, and then the disabled branch below strips +// bind_finding_traffic and every traffic parameter from the schemas while the +// tool descriptions keep promising the binding path. An agent then chases a tool +// that is not in its toolset (observed: "the tool bind_finding_traffic must be +// invoked as a tool", a bare Bash true, then grepping the transcripts and the +// binary). These notes ride on the tool descriptions, exactly like the capture +// notes above, so the standing guidance stays empty when the feature is off. +const ( + findingBindingOffProveGoalNote = "\nNote: automatic traffic binding is OFF on this server, so a finding cannot be bound to captured traffic here and cannot close an HTTP goal. Recorded findings stay visible; non-HTTP goals still close with an observed tool_output fact. An operator can enable binding (System settings) or bind captured traffic manually on the finding page, after which a bound finding closes the goal." + findingBindingOffReportFindingNote = "\nNote: automatic traffic binding is OFF on this server, so report_finding carries no traffic parameters and the bind_finding_traffic tool is not in your toolset. Findings still save with their evidence, but stay unverified and cannot prove a goal. Register a reproducible PoC in evidence as usual; do not guess traffic IDs and do not re-probe only to capture packets." + findingBindingOffHintNote = "\nNote: automatic traffic binding is OFF on this server, so hint traffic parameters are not in this schema. Keep the verified evidence and the known real traffic IDs in the hint text; the receiving task registers the finding and the operator can bind captured traffic later." +) + +func findingBindingOffToolNote(toolName string) string { + switch toolName { + case "prove_goal": + return findingBindingOffProveGoalNote + case "report_finding": + return findingBindingOffReportFindingNote + case "add_hint", "add_task_hint": + return findingBindingOffHintNote + default: + return "" + } +} + // Applied after ToolResolve: user descriptions and prompts remain intact, while // all actual reporters (including Planner and custom chat agents) see the same // API contract. Disabled/unbound tools are never reintroduced here. @@ -119,11 +146,18 @@ func findingWorkflowTools(agentKey string, tools []actool.CoreTool) ([]actool.Co desc += note decorated = true } + if note := findingBindingOffToolNote(tool.Name()); note != "" { + desc += note + decorated = true + } if decorated { tool = DecorateTool(tool, desc, schema) } out = append(out, tool) } + // The standing guidance stays empty: the binding-off notes ride on the + // tool descriptions, so a disabled deployment keeps the same contract the + // PG test asserts (def.FindingGuidance == ""). return out, "" } out := append([]actool.CoreTool(nil), tools...) diff --git a/agent/finding_workflow_test.go b/agent/finding_workflow_test.go index ba8fa76..693bd4d 100644 --- a/agent/finding_workflow_test.go +++ b/agent/finding_workflow_test.go @@ -39,6 +39,29 @@ func TestFindingWorkflowSharedAssemblyAndSwitch(t *testing.T) { if strings.Contains(system[0], "traffic_refs") != on { t.Fatalf("%s: guidance ignored switch: %v", role, on) } + if !on { + // The switch strips the tool and the schema, so the tool descriptions + // must say so: otherwise the agent chases bind_finding_traffic, which + // is not in its toolset, and burns turns on it. + if def.FindingGuidance != "" { + t.Fatalf("%s: disabled deployment must keep the standing guidance empty, got %q", role, def.FindingGuidance) + } + noted := false + for _, tool := range out { + if !strings.Contains(tool.Description(), "automatic traffic binding is OFF") { + continue + } + noted = true + // The tool that carries traffic parameters is the one whose + // schema lost them, so it must name the absent tool. + if tool.Name() == "report_finding" && !strings.Contains(tool.Description(), "bind_finding_traffic") { + t.Fatalf("%s: report_finding note must name the absent tool", role) + } + } + if !noted { + t.Fatalf("%s: disabled deployment must state on the tools that binding is off", role) + } + } if on && (!strings.Contains(system[0], "TCP") || !strings.Contains(system[0], "evidence_hint_id")) { t.Fatal("missing optional/handoff contract") }