Skip to content

feat(core): wire try_dispatch into decoding-level SSE ToolStream streaming path #3641

@bug-ops

Description

@bug-ops

Description

SpeculationEngine is now wired into the agent loop (#3636, PR #3640): the engine is instantiated and end_turn() is called correctly. However, try_dispatch is never called — the engine holds a running sweeper but no speculative tasks are ever submitted.

The missing piece is hooking try_dispatch into the LLM SSE streaming path so that as the decoder emits partial JSON tool-call tokens, the engine can fire speculative pre-execution.

Scope

  • File: crates/zeph-core/src/agent/ — the streaming consumption path where ToolStream SSE events arrive and partial JSON is assembled into ToolCall structs
  • PartialJsonParser in crates/zeph-core/src/agent/speculative/ is already implemented and awaiting integration
  • When a partial tool call becomes sufficiently confident (confidence >= config.confidence_threshold), call engine.try_dispatch(prediction, TrustLevel::Trusted) with a timeout per await-discipline rules

Expected Behavior

With [tools.speculative] mode = "decoding" set, speculative tool calls should fire during SSE streaming so the result is ready (or discarded) by the time the LLM finishes decoding.

Depends on

#3636 (merged in PR #3640)

Related

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