fix: keep root session span open across session.idle#70
Conversation
The opencode.session span and accumulated session totals were ended and deleted on the first session.idle event. Since a session keeps receiving turns after going idle, every subsequent turn's LLM/tool spans had no local session span to nest under and became orphaned root traces, and their token/cost contributions were silently dropped from session.total_*. Keep the session span and totals alive across session.idle (only snapshotting attributes), and finalize them in a new session.deleted handler, on session.error, or on process shutdown.
…havior Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brings in upstream's agent-metadata support (PR DEVtheOPS#67, DEVtheOPS#69) and the fix/issue-45 probe validation/release commits, on top of the session-span-stays-open-across-idle fix merged from fix/session-span-spans-whole-session. Resolved conflicts in src/handlers/session.ts and tests/handlers/spans.test.ts by keeping the session span/totals open across session.idle (this fork's fix) while also recording the agent.type attribute introduced upstream.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR separates session span teardown into two distinct lifecycle events. ChangesSession span lifecycle: idle vs. deleted
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Superseded by #71 — same fix, moved to a dedicated branch per CONTRIBUTING.md (this one was opened directly from |
Summary
opencode.sessionspan and accumulated session totals were ended and deleted on the firstsession.idleevent. Since a session keeps receiving turns after going idle, every subsequent turn's LLM/tool spans had no local session span to nest under and became orphaned root traces, with their token/cost contributions silently dropped fromsession.total_*.session.idle(only snapshotting attributes), and finalize them in a newsession.deletedhandler, onsession.error, or on process shutdown.Supersedes #64, which had the same fix but went stale against
mainafter #67/#68/#69 landed. This PR is rebased directly on currentmain(viaschemaitat:main, already merged with upstream) so the diff is clean.Test plan
bun test(282 pass)bun run typecheckbun --bun eslint src/handlers/session.ts tests/handlers/spans.test.tsbun run buildSummary by CodeRabbit
New Features
Improvements