Skip to content

fix(tools): wire reasoning model detection and compress_provider into agent#2367

Merged
bug-ops merged 1 commit intomainfrom
2357-wire-is-reasoning-model
Mar 28, 2026
Merged

fix(tools): wire reasoning model detection and compress_provider into agent#2367
bug-ops merged 1 commit intomainfrom
2357-wire-is-reasoning-model

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 28, 2026

Summary

  • Wire is_reasoning_model() / record_reasoning_quality_failure() into the agent tool execution path: quality failures (ToolNotFound, InvalidParameters, TypeMismatch) from reasoning-enhanced models (o1, o3, o4-mini, QwQ, DeepSeek-R1, Claude extended-thinking) now emit a reasoning_amplification WARN log and count in the anomaly window; gated by AnomalyConfig::reasoning_model_warning (default true)
  • Populate AuditEntry.error_phase from ToolErrorCategory::phase() in ShellExecutor, WebScrapeExecutor, and pre-execution verifier audit entries — was always null
  • Resolve compression.compress_provider from [[llm.providers]] at bootstrap and pass the named provider to handle_compress_context() LLM call; falls back to primary provider when field is empty or resolution fails

Changes

#2357is_reasoning_model() + error_phase wiring

  • tool_execution/mod.rs: new AnomalyOutcome::ReasoningQualityFailure { model, tool } variant; record_anomaly_outcome() dispatches to det.record_reasoning_quality_failure() when debug_state.reasoning_model_warning = true
  • tool_execution/native.rs (Err arm): sets ReasoningQualityFailure when is_quality_failure && is_reasoning_model(provider.name())
  • state/mod.rs: DebugState.reasoning_model_warning: bool field mirrors AnomalyConfig::reasoning_model_warning
  • builder.rs: stores anomaly_config.reasoning_model_warning into DebugState in apply_session_config()
  • shell/mod.rs, scrape.rs: log_audit now sets error_phase from e.category().phase().label()
  • native.rs pre-execution verifier block: error_phase = Some("setup")

#2356compress_provider wiring

  • state/mod.rs: ProviderState.compress_provider: Option<AnyProvider> (#[cfg(feature = "context-compression")])
  • builder.rs: with_compress_provider() builder method (feature-gated)
  • bootstrap/mod.rs: build_compress_provider() reads config.memory.compression.compress_provider and resolves via create_named_provider() (feature-gated)
  • runner.rs: wires build_compress_provider()with_compress_provider() inside #[cfg(feature = "context-compression")]
  • native.rs: handle_compress_context() uses providers.compress_provider.as_ref().unwrap_or(&self.provider)

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy -p zeph-tools -- -D warnings — clean
  • cargo clippy -p zeph-core -- -D warnings — clean
  • cargo clippy -p zeph-core --features context-compression -- -D warnings — clean
  • cargo nextest run -p zeph-tools -p zeph-core --lib --bins — 2047 passed
  • cargo nextest run -p zeph-core --features context-compression --lib --bins — 1212 passed

Closes #2357
Closes #2356

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 28, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 28, 2026 18:00
… agent (#2357, #2356)

- Add ReasoningQualityFailure variant to AnomalyOutcome; quality failures
  from is_reasoning_model() models now call record_reasoning_quality_failure()
  which emits a reasoning_amplification WARN log; gated by reasoning_model_warning
  flag in AnomalyConfig stored in DebugState
- Populate AuditEntry.error_phase from ToolErrorCategory::phase() in
  ShellExecutor.log_audit, WebScrapeExecutor.log_audit, and pre-execution
  verifier audit entries (was always None)
- Resolve compression.compress_provider from [[llm.providers]] at bootstrap
  via build_compress_provider(); store in ProviderState.compress_provider
  (context-compression feature-gated); handle_compress_context() uses the
  named provider with fallback to primary provider
@bug-ops bug-ops force-pushed the 2357-wire-is-reasoning-model branch from f8333e9 to 64883c9 Compare March 28, 2026 18:05
@bug-ops bug-ops merged commit 0356d75 into main Mar 28, 2026
25 checks passed
@bug-ops bug-ops deleted the 2357-wire-is-reasoning-model branch March 28, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant