Skip to content

refactor(agent-tools): replace send_stop_hint(&str) with enum to eliminate implicit match-arm coupling #4792

@bug-ops

Description

@bug-ops

Description

AgentChannel::send_stop_hint takes a primitive &str reason code (\"max_tokens\", \"cancelled\", etc.) instead of a typed enum. This creates implicit coupling: any new StopHint variant added to zeph_core::channel::StopHint MUST be mirrored at every dispatcher emit-site AND at AgentChannelView::send_stop_hint match arms without compiler enforcement.

The issue is acknowledged in the module-level doc comment of crates/zeph-agent-tools/src/channel.rs:21:
```
// TODO(critic): send_stop_hint takes a primitive &str reason instead of an enum.
// Any new variant added to zeph_core::channel::StopHint MUST be mirrored at dispatcher
// emit-sites AND at AgentChannelView::send_stop_hint match arms.
```

Reproduction Steps

  1. Add a new StopHint::SomeNewReason variant to zeph_core::channel::StopHint.
  2. The compiler does not flag AgentChannelView::send_stop_hint or dispatcher call-sites.
  3. The new reason is silently mapped to StopHint::Other or similar fallback.

Expected Behavior

Introducing a new StopHint variant causes compile errors at all dispatch call-sites, enforcing exhaustive handling.

Actual Behavior

No compile-time feedback — silent fallback. Only caught by manual audit or runtime tests.

Environment

Logs / Evidence

Module doc comment explicitly tags this as a known debt item (TODO(critic)).

Metadata

Metadata

Assignees

Labels

P4Long-term / exploratoryrefactorCode refactoring without functional changes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions