feat(observability): add response feedback tracking to openapi#1660
feat(observability): add response feedback tracking to openapi#1660yeshion23333 merged 12 commits intomainfrom
Conversation
Persist response, feedback, and outcome signals so OpenAPI clients can attach stable feedback to assistant replies. Sync the same business events to Langfuse to make Q&A effectiveness observable across restarts.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
This commit removes the response tracking, feedback submission, and Langfuse integration features. The changes include: - Removing ResponseCompletedEvent and related response_id fields - Removing feedback models and endpoints - Removing Langfuse client integration - Simplifying the OpenAPI channel by removing response persistence - Updating tests to reflect these removals
# Conflicts: # bot/vikingbot/agent/loop.py
- remove unnecessary blank lines - reorder imports to follow conventions - fix string formatting in logging - group related imports together - fix import ordering in multiple files
yeshion23333
left a comment
There was a problem hiding this comment.
这次改动方向是对的(response_id + feedback + outcome + Langfuse 关联链路基本完整),但当前还有几个需要先修复的问题,建议先不合入:
- 阻塞:CI lint 未通过
bot/vikingbot/agent/memory.py:57:F841,变量abstract赋值后未使用bot/vikingbot/channels/mochat.py:189:F821,MochatConfig未定义
- 高风险:反馈写回存在并发覆盖风险
bot/vikingbot/channels/openapi.py在_handle_feedback中通过独立SessionManager读 session、改 metadata、再全量savebot/vikingbot/session/manager.py:221起save为整文件重写- 与
AgentLoop并发写 session 时,存在旧快照覆盖新消息/新 metadata 的风险
- 口径问题:
abandoned语义与设计文档不一致
- 当前实现
abandoned = bool(user_messages) and not relevant_feedback(bot/vikingbot/observability/outcome.py) - 这更像“有后续用户消息但无反馈”,与文档中“回答后用户离开/放弃”的语义不一致
- 统计污染风险:heartbeat 可能被当作 follow-up 参与 outcome 评估
_evaluate_previous_response_outcome在入站消息前统一执行(bot/vikingbot/agent/loop.py)- heartbeat 也是入站消息,可能误触发
reasked/follow_up判定
- 数据质量:反馈请求约束偏弱
FeedbackRequest对feedback_score缺少范围/条件约束user_id可由请求体覆盖,后续做归因统计时会带来可信性问题
建议至少完成:
- 修复 lint 红线
- 处理 session 并发写一致性(避免全量覆盖)
- 对齐 outcome 口径并排除 heartbeat 干扰
- 补充并发与口径相关回归测试
修完以上点后,这个 PR 就接近可合并状态了。
Remove unused abstract attribute from MemoryStore and update config parameter type in resolve_require_mention to MochatChannelConfig for better type clarity
…or clarity refactor(session): add session locking and metadata merging - Implement per-session file locks to prevent concurrent write conflicts - Add metadata merging logic to preserve existing data during updates - Introduce update_session method for atomic read-modify-write operations fix(agent): skip outcome evaluation for heartbeat messages
|
感谢这轮修复提交,问题定位和修改都很到位,辛苦了! |
Summary
This PR adds an end-to-end feedback observability flow for Vikingbot, including stable
response_idtracking, explicit feedback submission, and implicit response outcome evaluation.It connects assistant responses, feedback events, follow-up user turns, and Langfuse metadata so feedback can be attributed at the response level instead of only at the session level.
Type of Change
Testing
Describe how to test these changes:
Testing details:
bot/vikingbot/agent/loop.pykeeps both:final_reasoning_contentpersistenceresponse_id,RESPONSE_COMPLETED, and outcome evaluation flowpython -m py_compile ...Notes:
pytestexecution was blocked by environment issues:_sqlite3forpytest-covopenvikingpackage resolutionpr.yml)Related Issues
Checklist
Description
Changes Made
response_idgeneration and propagation for assistant responsesresponse_idin OpenAPI chat responses and streaming response events/bot/v1/feedbacksupport in Vikingbot OpenAPI channel/bot/v1/feedbackproxy support inopenviking/server/routers/bot.pyRESPONSE_COMPLETEDFEEDBACK_SUBMITTEDRESPONSE_OUTCOME_EVALUATEDresolvedreaskedfollow_upabandonedpositive_feedbacknegative_feedbackreasoning_contentKey Files
bot/vikingbot/agent/loop.pybot/vikingbot/channels/openapi.pybot/vikingbot/channels/openapi_models.pybot/vikingbot/observability/outcome.pybot/vikingbot/integrations/langfuse.pybot/vikingbot/utils/tracing.pybot/vikingbot/providers/litellm_provider.pybot/vikingbot/providers/openai_compatible_provider.pyopenviking/server/routers/bot.pyopenviking/server/bootstrap.pyMerge Compatibility Notes
This branch has been merged with the latest
main.The only merge conflict was in
bot/vikingbot/agent/loop.py, and it was resolved by keeping both sides’ intended behavior:final_reasoning_contenthandling and persistencemain’s response-level tracing and outcome evaluation path based onresponse_idThis avoids regressions in:
Additional Notes
Relevant tests added/updated:
bot/tests/test_agent_loop_outcome.pybot/tests/test_langfuse_outcome_metadata.pybot/tests/test_outcome_evaluator.pybot/tests/test_openapi_auth.pytests/server/test_bot_proxy_auth.pytests/unit/test_server_bootstrap_bot_gateway.pyRelevant docs added/updated:
bot/docs/vikingbot-feedback-observability-design.mdbot/docs/vikingbot-langfuse-local-setup.mdbot/docs/vikingbot-phase1-validation-with-openviking-server.mdbot/docs/vikingbot-phase2-feedback-validation-with-openviking-server.mdbot/docs/vikingbot-phase3-outcome-validation-with-openviking-server.md