Channels Refactor Phase 3 | Refactor Evaluations Channel#3089
Channels Refactor Phase 3 | Refactor Evaluations Channel#3089
Conversation
Add EvaluationChannel and EvalsBotInteractionStage to channels_v2, update tasks.py imports, remove old implementation from apps/chat/channels.py, and replace old tests with new pipeline-based tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThe PR migrates Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/channels/channels_v2/evaluation_channel.py`:
- Around line 57-60: The current _create_context implementation replaces
ctx.channel_context with a new dict, which can drop keys added by the base
class; instead call super()._create_context(message) to get ctx and then update
or set the participant data into the existing ctx.channel_context (e.g., ensure
ctx.channel_context is a dict and use ctx.channel_context.update({...}) or
ctx.channel_context.setdefault("participant_data", ...)) so you mutate the
existing MessageProcessingContext.channel_context rather than overwriting it.
In `@apps/channels/channels_v2/stages/core.py`:
- Around line 106-113: The fallback lookup uses .first() which can return an
older open session; change the query on ExperimentSession to pick the newest
non-complete session (e.g., replace .first() with
.order_by("-created_at").first() or .latest("created_at") to match the "normal
resolution" logic), and add a regression test that creates two open
ExperimentSession rows for the same participant and verifies /reset closes the
newest session only; update any test helper that constructs sessions to ensure
timestamps differ so the ordering is meaningful.
- Around line 447-450: The call to ctx.bot.process_input currently omits the
persisted human message, breaking the linkage used by EvalsBot/PipelineBot;
update the call in core.py where ctx.bot_response is set to pass the saved human
message (e.g., human_message=ctx.human_message) into
EvalsBot.process_input()/PipelineBot.process_input(), and add a regression test
in test_evals_bot_interaction.py that reproduces the detached-history failure
(write a failing test that asserts the eval run has the same ChatMessage
linkage) then make sure the test passes after the fix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5abe468a-14c2-42ec-a26e-ae13259c542c
📒 Files selected for processing (13)
apps/channels/channels_v2/channel_base.pyapps/channels/channels_v2/evaluation_channel.pyapps/channels/channels_v2/pipeline.pyapps/channels/channels_v2/stages/core.pyapps/channels/channels_v2/stages/terminal.pyapps/channels/tasks.pyapps/channels/tests/channels/concrete/test_evaluation_channel.pyapps/channels/tests/channels/concrete/test_web_channel.pyapps/channels/tests/channels/stages/test_evals_bot_interaction.pyapps/channels/tests/channels/stages/test_session_resolution.pyapps/channels/tests/test_evaluation_channel.pyapps/chat/channels.pydocs/plans/channels_refactor.md
💤 Files with no reviewable changes (1)
- apps/channels/tests/test_evaluation_channel.py
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
- Mutate ctx.channel_context instead of replacing it wholesale in EvaluationChannel
- Add .order_by("-created_at") to reset fallback session lookup for consistency
- Forward ctx.human_message into EvalsBot.process_input() to preserve pipeline state linkage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Product Description
No change
Technical Description
Phase 3 of the channels refactor: migrates
EvaluationChannelfrom the oldChannelBaseinapps/chat/channels.pyto the new stage-based pipeline architecture inapps/channels/channels_v2/.Key changes:
New
EvaluationChannel(apps/channels/channels_v2/evaluation_channel.py): Implements the evaluation channel using the new pipeline architecture. UsesNoOpSender(no messages sent externally),TracingService.empty()(no OCS tracer), and passesparticipant_dataviactx.channel_context.New
EvalsBotInteractionStage(apps/channels/channels_v2/stages/core.py): Specialized bot interaction stage for evaluations that usesEvalsBotinstead ofget_bot(). Readsparticipant_datafromctx.channel_contextrather than the DB-backedParticipantDatamodel.Pipeline composition: The evaluation pipeline omits
SessionResolutionStage(session is always pre-set),ConsentFlowStage, and all sending stages (ResponseSendingStage,SendingErrorHandlerStage). UsesEvalsBotInteractionStageinstead ofBotInteractionStage.Old implementation removed: Deleted
EvaluationChannelclass fromapps/chat/channels.pyand its tests fromapps/channels/tests/test_evaluation_channel.py.Import updates: Updated
apps/channels/tasks.pyto import from the new location.Additional fixes from code review (commit 1):
/resetnot ending the old session whenctx.experiment_sessionisNone(channels that don't pre-set sessions like API/Telegram)RESET_COMMANDconstantctx.messageinResponseFormattingStageRECIPROCAL and user_sent_voicenow correctly grouped with parentheses)Demo
N/A — internal refactor with no user-facing changes.
Docs and Changelog