Skip to content

feat(core): wire SpeculationEngine try_dispatch into SSE streaming and PASTE skill activation#3654

Merged
bug-ops merged 2 commits intomainfrom
3641-speculation-try-dispatch
May 6, 2026
Merged

feat(core): wire SpeculationEngine try_dispatch into SSE streaming and PASTE skill activation#3654
bug-ops merged 2 commits intomainfrom
3641-speculation-try-dispatch

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 6, 2026

Summary

  • SSE decoding path (feat(core): wire try_dispatch into decoding-level SSE ToolStream streaming path #3641): extend Claude SSE parser with ToolBlockStart/InputJsonDelta/ToolCallComplete events; new SpeculativeStreamDrainer fires try_dispatch(Trusted) with 2 s timeout when partial tool call confidence exceeds threshold; ToolRequestBody gains stream: bool; AnyProvider::chat_with_tools_stream with streaming fallback
  • PASTE pattern path (feat(core): wire SpeculationEngine try_dispatch into PASTE pattern skill activation path #3642): run_paste_skill_activation() calls PatternStore::predict() per active skill at context assembly time; observe_paste_transition() records transitions for pattern learning; PatternStore initialized only when mode=Pattern|Both
  • Shared: is_tool_speculatable delegated through CompositeExecutor, PolicyGateExecutor, TrustGateExecutor; PartialJsonParser rejects inputs > 512 KB; confidence_threshold() accessor added to SpeculationEngine

Test plan

  • cargo +nightly fmt --check — PASS
  • cargo clippy --workspace --lib --bins -- -D warnings — PASS (0 warnings)
  • cargo nextest run --config-file .github/nextest.toml --workspace --lib --bins — 8928/8928 PASS
  • New unit test tool_block_start_enables_incremental_dispatch verifies BUG-2 fix (tool metadata timing)
  • SpeculativeStreamDrainer has 6 unit tests covering core dispatch path, timeout, and thinking block accumulation
  • Live API session required before merge (LLM serialization gate): SSE path touches claude/mod.rs and types.rs

Closes #3641, #3642

@github-actions github-actions Bot added enhancement New feature or request size/XL Extra large PR (500+ lines) documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate tests Test-related changes dependencies Dependency updates labels May 6, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 6, 2026 12:07
bug-ops added 2 commits May 6, 2026 14:08
…d PASTE skill activation

Wire two speculation dispatch paths:

SSE decoding path (#3641): extend Claude SSE parser with ToolBlockStart/InputJsonDelta/
ToolCallComplete events so SpeculativeStreamDrainer can populate tool metadata before
delta events arrive. Add chat_with_tools_stream() to LlmProvider + AnyProvider with
streaming fallback. When partial tool call confidence exceeds threshold, call
try_dispatch(Trusted) with a 2 s timeout. ToolRequestBody gains stream:bool to send
a proper SSE request to the Claude API.

PASTE pattern path (#3642): run_paste_skill_activation() calls PatternStore::predict()
per active skill at context assembly time and dispatches candidates above threshold
with per-skill trust level (500 ms timeout). observe_paste_transition() records
tool transitions for pattern learning (200 ms, fire-and-forget). PatternStore is
initialized only when mode=Pattern or mode=Both.

Shared: is_tool_speculatable now delegated through CompositeExecutor, PolicyGateExecutor,
and TrustGateExecutor so the gate reaches concrete executors in production. PartialJsonParser
rejects inputs exceeding 512 KB (returns Malformed). confidence_threshold() accessor added
to SpeculationEngine.

Closes #3641, #3642
…n stream_drainer tests; fix broken rustdoc intra-doc links for ToolSseStream
@bug-ops bug-ops force-pushed the 3641-speculation-try-dispatch branch from 471e9a5 to d692ff1 Compare May 6, 2026 12:10
@github-actions github-actions Bot removed tests Test-related changes dependencies Dependency updates labels May 6, 2026
@bug-ops bug-ops merged commit 8a921f5 into main May 6, 2026
32 checks passed
@bug-ops bug-ops deleted the 3641-speculation-try-dispatch branch May 6, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant