Skip to content

fix(tools): wire is_reasoning_model() and error_phase into agent tool execution path #2357

@bug-ops

Description

@bug-ops

Summary

PR #2354 added scaffolding for reasoning model hallucination detection and tool invocation phase taxonomy, but the helpers are not wired into the agent execution path:

  1. is_reasoning_model() — implemented in anomaly.rs, exported from zeph-tools, but never called from zeph-core or the agent loop
  2. record_reasoning_quality_failure() on AnomalyDetector — implemented but never called from production code
  3. error_phase: Option<String> in AuditEntry — field exists but is always None in every code path; ToolInvocationPhase::phase() is never used to populate it
  4. reasoning_model_warning flag in OrchestrationConfig — declared, default true, but never read from the agent loop

Expected behavior

  • When the active provider model name matches is_reasoning_model() and a tool call results in ToolNotFound/InvalidParameters/TypeMismatch, record_reasoning_quality_failure() should be called on the anomaly detector
  • AuditEntry.error_phase should be populated from ToolErrorCategory::phase() when an error entry is written
  • reasoning_model_warning flag should gate whether record_reasoning_quality_failure emits the WARN log

Reproduction

Run live agent session. Inspect audit-test.jsonl — every entry has "error_phase":null. Grep production code: is_reasoning_model and record_reasoning_quality_failure have zero callers outside zeph-tools.

Files to change

  • crates/zeph-core/src/agent/ — add reasoning model check when processing tool results
  • crates/zeph-tools/src/shell/mod.rs, scrape.rs — populate error_phase from ToolErrorCategory::phase() in log_audit calls

Related: #2284 (research issue not auto-closed despite PR #2354 "Closes #2284")

Metadata

Metadata

Assignees

Labels

P2High value, medium complexitybugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions