← Back to PRs

#23723: feat(message): improve send param ergonomics and actionable routing errors

by SmithLabsLLC open 2026-02-22 16:39 View on GitHub →
docs channel: discord channel: telegram agents size: L
## Summary This PR improves message send ergonomics around the most common source of avoidable failures: confusion between `channel`, `target`, legacy `to`, and `replyTo`. ### What changed 1. **Actionable validation/error messages** - Detects and rejects conflicting destination fields (for example `target` + `to` with different values). - Rejects `targets` on non-`broadcast` actions with clear guidance. - Produces a targeted error when `replyTo` is provided without a destination (`replyTo` is threading metadata, not the destination). - Improves unknown-channel errors when `channel` looks like a destination value (suggests moving it to `target`). 2. **Safe compatibility aliases** - Keeps legacy destination compatibility while normalizing behavior: - `to` remains supported as a legacy alias for destination routing. - `replyToId` / `reply_to` are normalized to `replyTo`. - `broadcast` now accepts single-destination aliases (`target`/`to`) and normalizes them into `targets`. - Auto-inferrs channel from provider-prefixed targets (e.g. `telegram:123456`) when channel is omitted. 3. **Docs + prompt guidance updates** - Updated docs and examples to prefer `target` over `to`. - Added explicit guidance that `replyTo` is not a destination field. - Updated agent system prompt hint from `to` to `target` (while noting `to` is legacy). 4. **Tests** - Added new `channel-target` unit tests for target mapping + improved error text. - Expanded message-action-runner tests for: - conflicting field validation - `replyTo` missing-target errors - non-broadcast `targets` validation - broadcast alias handling - channel inference from provider-prefixed target - channel misuse error clarity - `replyToId` normalization threading path - Added message tool schema alias coverage and system prompt assertion updates. ## Backward compatibility The change is intentionally scoped and backward-compatible: legacy fields are still accepted where safe, but invalid/ambiguous combinations now fail early with explicit remediation guidance. ## Tests run ```bash pnpm vitest run --config vitest.unit.config.ts --maxWorkers=1 \ src/infra/outbound/channel-target.test.ts \ src/infra/outbound/message-action-runner.threading.test.ts \ src/infra/outbound/message-action-runner.test.ts \ src/agents/tools/message-tool.test.ts \ src/agents/system-prompt.test.ts ``` <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR improves message sending ergonomics by adding better validation and actionable error messages for destination routing. The changes normalize `target`, `to`, and `channelId` fields while maintaining backward compatibility through aliases. Key improvements include conflict detection for multiple destination fields, clear error messages when `replyTo` is provided without a destination, rejection of `targets` on non-broadcast actions, and automatic channel inference from provider-prefixed targets (e.g., `telegram:123`). The implementation is well-tested with comprehensive unit tests covering edge cases and error paths. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are well-structured with comprehensive test coverage (158+ new test lines), maintain backward compatibility through careful aliasing, and improve error handling with actionable messages. The logic is sound, validation is thorough, and all changes are additive with proper fallbacks. - No files require special attention <sub>Last reviewed commit: 6941c85</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs