Repository navigation
fix(channels example): pi adapter rejects unsupported attachments, keeps message ids across forks - #2491
Draft
cjol wants to merge 4 commits into
Draft
fix(channels example): pi adapter rejects unsupported attachments, keeps message ids across forks#2491cjol wants to merge 4 commits into
cjol wants to merge 4 commits into
Conversation
|
Contributor
|
✅ agents import sizes: no significant changes ( |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two gaps in the pi harness adapter of the Channels example (
piChannelsHarnessinexamples/next/channels/src/pi/channels-harness.ts): dropped attachments and lost message ids after a fork. It also adds the example's first test setup.Why
toUserInputsilently dropped any part that was not an inline base64 image, so pi answered a prompt missing the PDF or remote image the user sent, with no sign anything was lost.resolveonly looked at the fork's own submissions and cache namespace, but the inherited entries were placed by the parent session.conversationIdon inherited entries, so resolving by that needs no fork hook, covers forks of forks, and falls back to pi's own submission records after eviction. Copying would need a scan at fork time and would miss mappings not yet cached.Code Changes
toUserInputnow throws for parts pi cannot take (non-image, non-text files, or files by URL), naming the media type. The submit fails before anything is recorded, so Channels rejects the event.text/*files are decoded into text parts, since pi takes text. Images use the part'smediaTypeand accept data URLs with extra parameters.transcript()groups user entries byentry.conversationIdand resolves each group against that session's operation records.src/tests/: a Workers-pool vitest with a Durable Object runningPiHarnesson pi-ai's faux provider, modelled onexamples/next/harnesses/pi/src/tests. Addstestandtypecheckscripts, and the vitest pool types to the example'stsconfig.json.