Skip to content

feat(core): set ToolStartEvent.speculative = true when committing a speculative result #3643

@bug-ops

Description

@bug-ops

Description

ToolStartEvent has a speculative: bool field used by the TUI to render [spec] prefix. In PR #3640 (#3636) all production call sites correctly keep speculative: false for normal dispatch. The speculative: true path needs to be wired when the speculation engine commits a cached result via try_commit.

Scope

  • File: crates/zeph-core/src/agent/tool_execution/native.rsbuild_tier_call_futures (around line 2509 per critic analysis)
  • Before normal dispatch, call engine.try_commit(&tool_call) — if it returns Some(result), use the cached result and emit ToolStartEvent { speculative: true, .. }
  • If try_commit returns None, proceed with normal dispatch (keep speculative: false)
  • The ToolStartEvent ordering concern (critic I3): suppress or defer stamp_and_send_tier_start for indices where a speculative commit fires

Acceptance

  • TUI shows [spec] prefix on committed speculative tool calls
  • SpeculativeMetrics.committed increments
  • speculative: false path unchanged for normal dispatch

Depends on

#3636 (merged), #3641 (try_dispatch wired — needed to have results to commit)

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