Skip to content

refactor(channels): move message-format projections into Channels - #2510

Closed
cjol wants to merge 1 commit into
mainfrom
refactor/channels-projections
Closed

cjol wants to merge 1 commit into
mainfrom
refactor/channels-projections

Conversation

@cjol

@cjol cjol commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

This PR gives each harness vendor's message-format conversion one home: a projection under agents/experimental/channels/projections/, one entry point per vendor. It also moves the pi harness adapter out of the channels example into agents/harness/pi.

Why

  • Conversions between vendor formats and Channels transcript messages and response chunks were scattered. The AI SDK ones lived in harness/ai-sdk/turns.ts, mixed with turn logic. The pi ones lived in examples/next/channels, built on a second projection borrowed from the pi harness example.
  • The AI SDK chat transport, a Client of the Web Channel, imported from the harness module to reuse the reverse conversions, so a Client depended on a harness.
  • OpenCode and other harnesses will need the same conversions, and the Channels format is expected to move to core. Putting the projections in one place now means the later move to src/projections/ only changes paths.
  • Projections stay under Channels, rather than a top-level src/projections/, until the format is promoted to core, because they depend on the experimental Channels protocol types.
  • Each vendor gets its own subpath, rather than re-exports from the Channels root, so importing Channels does not load ai or @earendil-works/pi-ai.

Public API Surface

Symbol Entry point Notes
toResponseChunks, toTranscriptMessage, toUIMessageChunk, toUIMessage, AiSdkProjectionOptions agents/experimental/channels/projections/ai-sdk Moved from agents/harness/ai-sdk; AiSdkConversionOptions is renamed
toTranscriptMessages, toToolOutputChunk, PiChunkProjection agents/experimental/channels/projections/pi New: pi-durable entries and live events to transcript messages and response chunks
piChannelsHarness, PiChannelsHarnessOptions agents/harness/pi New: PiHarness behind the shared harness interface, moved from the channels example

Code Changes

  • projections/ai-sdk.ts holds the conversion half of the old turns.ts. turns.ts keeps answerToolCall, awaitsInput and ToolCallAnswer, which are harness turn logic.
  • projections/pi.ts projects entries straight to TranscriptMessage, so it no longer goes through the pi example's PiMessage. That example keeps PiMessage as its own UI view model, since it runs without Channels.
  • PiChunkProjection keeps the open parts of one run, because pi addresses blocks by index. It holds no harness state.
  • harness/pi/channels.ts is the old example adapter with message formats delegated to the projection. The example's PiAgent now imports it from agents/harness/pi.
  • docs/CONTEXT.md adds Client and Projection, narrows Harness adapter to sessions, operations and results, and stops using "client" for a participant. Stale "Adapter" wording for a Channel in channel.ts and the Slack Channel is gone.

Compatibility

  • agents/harness/ai-sdk no longer exports the AI SDK conversions or AiSdkConversionOptions. Import them from agents/experimental/channels/projections/ai-sdk. Neither entry point has been released yet, and the pending changeset for agents/harness/ai-sdk is updated to match.

Devin Review

AI SDK and pi message-format conversions now live under
agents/experimental/channels/projections, one entry point per vendor.
piChannelsHarness moves from the channels example into agents/harness/pi.
CONTEXT.md gains Client and Projection.
@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a3d87a8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Minor
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@agent-think

agent-think Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🟢 agents import sizes: 4 entry points changed, no growth

Entry point Exports Largest gzip change Size now
🆕 agents/experimental/channels/projections/ai-sdk 4 new — 955 B
🆕 agents/experimental/channels/projections/pi 3 new — 947 B
🆕 agents/harness/pi 1 new — 3.4 KiB
➖ agents/harness/ai-sdk 4 removed — —
Changed exports (12)
Import Gzip change Size now
🆕 agents/harness/pi#piChannelsHarness — 3.4 KiB
🆕 agents/experimental/channels/projections/ai-sdk#toResponseChunks — 955 B
🆕 agents/experimental/channels/projections/pi#PiChunkProjection — 947 B
🆕 agents/experimental/channels/projections/ai-sdk#toTranscriptMessage — 783 B
🆕 agents/experimental/channels/projections/pi#toTranscriptMessages — 632 B
🆕 agents/experimental/channels/projections/ai-sdk#toUIMessage — 260 B
🆕 agents/experimental/channels/projections/ai-sdk#toUIMessageChunk — 229 B
🆕 agents/experimental/channels/projections/pi#toToolOutputChunk — 221 B
➖ agents/harness/ai-sdk#toResponseChunks — —
➖ agents/harness/ai-sdk#toTranscriptMessage — —
➖ agents/harness/ai-sdk#toUIMessage — —
➖ agents/harness/ai-sdk#toUIMessageChunk — —
How this works

Each runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement.

Compared 0a25ca92 → a3d87a83 · workflow run · reported by agent-think[bot]

@pkg-pr-new

pkg-pr-new Bot commented Oct 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2510

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2510

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2510

hono-agents

npm i https://pkg.pr.new/hono-agents@2510

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2510

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2510

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2510

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2510

commit: a3d87a8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant