feat(channel): answer follow-ups after a mention subscribes - #30
Closed
BenTaylorDev wants to merge 1 commit into
Closed
feat(channel): answer follow-ups after a mention subscribes#30BenTaylorDev wants to merge 1 commit into
BenTaylorDev wants to merge 1 commit into
Conversation
`onMention` ran the agent but never subscribed the conversation, and no `onMessage` handler was registered at all — so OpenTag answered only when explicitly addressed, on every single turn. A mention now subscribes the conversation and runs the agent; later messages in that conversation run it too, guarded by `isSubscribed()` so the bot stays silent in conversations it was never invited into. Dispatch is exclusive — a mentioned turn goes to `onMention` whenever any is registered — so the mention that subscribes still runs exactly once. The existing error handling moves into a shared `runTurn` handler rather than being duplicated across both entry points. The tests count agent runs from inside the `FakeAgent` script rather than from a field on the agent: every turn runs on a clone, and `FakeAgent.clone()` copies the remaining script but resets its own counters, so instance state under-reports. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
|
Closing — redundant. |
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.
What
onMentionran the agent but never subscribed the conversation, and noonMessagehandler was registered at all — so OpenTag answered only when explicitly addressed, on every single turn.isSubscribed()so the bot stays silent in conversations it was never invited into.reportRecoverableError,AggregateErrorwhen the reply itself fails) moves into a sharedrunTurnhandler instead of being duplicated across both entry points.Dispatch is exclusive in
channels-core— a mentioned turn goes toonMentionwhenever any handler is registered, and toonMessageotherwise — so the mention that subscribes still runs the agent exactly once.runAgent(managedRunInput(message))is kept rather than a barerunAgent():managedRunInputcarries the multimodal content parts and the per-platform tools/context that a managed turn needs.Testing
Two new tests in
app/channel.test.ts, both driven throughFakeAdapter's ingress sink with explicitoperation.mentioned(turn dedup keys offlogicalMessageId/revisionId, so each turn gets its own id):stays quiet in a conversation that never addressed it— one non-mention turn, zero agent runs.answers follow-ups once a mention subscribes that conversation— mention inc1, follow-up inc1, unrelated non-mention inc2; exactly 2 runs.Red-checked — with
app/channel.tsxstashed, the second test fails, so it genuinely covers the new wiring:With the change:
Runs are counted from inside the
FakeAgentscript, not from a field on the agent: every turn runs on a clone, andFakeAgent.clone()copies the remaining script but resets its own counters, soCapturingAgent.callsreads 0 even when the agent did run.Pre-existing red, unchanged by this PR
pnpm check-typesandpnpm testare already failing onmainfrom drift against@copilotkit/channels@0.6.0(PlatformUserno longer exported,ProviderActor.kindnow required,FakeAgent.clone()resetting counters). Measured before and after:tscerrorsmain)The failing test names are byte-identical before and after (
diffof the sorted failure list is empty), and no error is reported inapp/channel.tsx. Fixing that drift is out of scope here.🤖 Generated with Claude Code