feat(litellm): forward taskId as X-Zoo-Session-ID request header#591
feat(litellm): forward taskId as X-Zoo-Session-ID request header#591awschmeder wants to merge 2 commits into
Conversation
Closes: Zoo-Code-Org#590 LiteLLM recognizes X-<vendor>-Session-ID headers for per-conversation request correlation in logs and spend tracking. This follows the same convention used by Claude Code (x-claude-code-session-id) and GitHub Copilot (x-copilot-session-id). The header is injected only when metadata.taskId is present, passed as the second argument to client.chat.completions.create() alongside the existing .withResponse() pattern so no existing tests need to change.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds per-conversation request correlation to LiteLLM by forwarding the active task ID as an ChangesLiteLLM Session ID Header
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |

Related GitHub Issue
Closes: #590
Description
The
LiteLLMHandlernow forwards the active task ID as anX-Zoo-Session-IDHTTP request header so LiteLLM proxy operators can correlate individual API calls back to a specific Zoo Code conversation thread.Implementation details:
requestHeadersmap built frommetadata?.taskId; the header is only sent when a task ID is present (no-op for callers that do not supply one).client.chat.completions.create(requestOptions, { headers: requestHeaders }), chained with the existing.withResponse()pattern -- no changes to the mock shape in existing tests were needed.x-<vendor>-session-idconvention used by Claude Code (x-claude-code-session-id) and GitHub Copilot (x-copilot-session-id).completePromptis intentionally unchanged -- it receives nometadata/taskId, so there is no session ID to forward.Test Procedure
Automated:
cd src && npx vitest run api/providers/__tests__/lite-llm.spec.ts-- all 30 tests pass (28 pre-existing + 2 new).New tests added in
describe("session ID header"):X-Zoo-Session-IDequals thetaskIdwhen metadata is provided.taskIdis provided.Manual: configure Zoo Code with a LiteLLM proxy and inspect proxy logs -- requests should show
x-zoo-session-idtagged with the conversation task UUID.Pre-Submission Checklist
Screenshots / Videos
N/A -- no UI changes.
Documentation Updates
Additional Notes
The header name
X-Zoo-Session-IDwas chosen (overX-Zoo-Task-IDused by the Zoo Gateway) to match LiteLLMs native session-tracking header convention and align with the industry pattern.Get in Touch
awschmeder on Discord.
Summary by CodeRabbit
New Features
Tests