Skip to content

feat: wire SpeculationEngine into agent loop via SpeculativeConfig #3636

@bug-ops

Description

@bug-ops

Description

SpeculationEngine is fully implemented in crates/zeph-core/src/agent/speculative/mod.rs with both Decoding mode (issue #2290) and Pattern/PASTE mode (issue #2409). SpeculativeConfig is declared in crates/zeph-config/src/tools.rs (line 1060) and included in ToolsConfig (line 1263). However, SpeculationEngine is never instantiated in the agent loop and all tool dispatch call sites hardcode speculative: false.

Reproduction Steps

  1. Review crates/zeph-core/src/agent/speculative/mod.rs:31#![allow(dead_code)] confirms intentional deferral
  2. Search for SpeculationEngine outside the speculative module: grep -rn "SpeculationEngine" crates/ | grep -v "speculative/" — zero results
  3. Search call sites: grep -rn "speculative: false" crates/zeph-core/src/ — 7 hardcoded false values

Hardcoded false call sites

  • crates/zeph-core/src/channel.rs:1061, 1088, 1111
  • crates/zeph-core/src/agent/channel_impl.rs:113
  • crates/zeph-core/src/agent/tool_execution/native.rs:590, 687, 2194

Expected Behavior

When tools.speculative.mode is set to Decoding or Pattern in the config, the agent loop should instantiate SpeculationEngine from SpeculativeConfig and pass it through to tool dispatch so speculative execution can fire.

Actual Behavior

SpeculativeConfig is read from TOML but never used. All tool dispatch calls receive speculative: false regardless of config. The SpeculationEngine type has #![allow(dead_code)] suppressing warnings on the entire module.

Environment

  • Version: v0.20.1 (commit a17a5bd)
  • Features: full

Logs / Evidence

$ grep -rn "SpeculationEngine" crates/ | grep -v "speculative/"
(no output — zero instantiation sites outside the module)

$ grep -rn "speculative: false" crates/zeph-core/src/
crates/zeph-core/src/channel.rs:1061:                speculative: false,
crates/zeph-core/src/channel.rs:1088:                speculative: false,
crates/zeph-core/src/channel.rs:1111:                speculative: false,
crates/zeph-core/src/agent/channel_impl.rs:113:            speculative: false,
crates/zeph-core/src/agent/tool_execution/native.rs:590:                speculative: false,
crates/zeph-core/src/agent/tool_execution/native.rs:687:                        speculative: false,
crates/zeph-core/src/agent/tool_execution/native.rs:2194:                    speculative: false,

Implementation Notes

  • SpeculationEngine is in crates/zeph-core/src/agent/speculative/mod.rs
  • SpeculativeConfig is in crates/zeph-config/src/tools.rs:1060; included via ToolsConfig::speculative at line 1263
  • Wire: instantiate SpeculationEngine in crates/zeph-core/src/agent/builder.rs from config.tools.speculative, propagate through ToolExecutionContext, and replace hardcoded false with config-driven flag at the 7 call sites above

Metadata

Metadata

Assignees

Labels

P2High value, medium complexityenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions