Skip to content

ai-chat: forward or document body behavior during tool continuation path #887

@ask-bonk

Description

@ask-bonk

Context

In #886, we added forwarding of custom body fields to onChatMessage via options.body. However, this only applies to the initial CF_AGENT_USE_CHAT_REQUEST path. The tool continuation path (CF_AGENT_TOOL_RESULT) does not forward body, so options.body will be undefined during auto-continue after client tool results.

Problem

Users who rely on body data (e.g., model selection, temperature) for every onChatMessage invocation will find it missing on tool continuation calls. They would need to manually store it on the first call (e.g., in Durable Object state) and retrieve it on subsequent calls.

Possible approaches

  1. Persist and re-forward body — Store the custom body fields from the initial request and automatically pass them through on tool continuations so options.body is always available.
  2. Document the current behavior — Make it clear in docs/JSDoc that options.body is only populated on the initial chat request and is undefined during tool continuations, with guidance on how users can persist it themselves.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions