feat(ai-observability): route eval-report agent through the ai-gateway#65043
Draft
brandonleung wants to merge 1 commit into
Draft
feat(ai-observability): route eval-report agent through the ai-gateway#65043brandonleung wants to merge 1 commit into
brandonleung wants to merge 1 commit into
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog/temporal/ai_observability/eval_reports/report_agent/graph.py:34-41
**Superfluous wrapper function**
`_get_llm` is now a single-line delegation to `build_openai_chat_client` with an identical signature and no added logic. By simplicity rules 3 (OnceAndOnlyOnce) and 4 (no superfluous parts), the wrapper should be deleted and the call site on line 196 updated to call `build_openai_chat_client(EVAL_REPORT_AGENT_MODEL, EVAL_REPORT_AGENT_TIMEOUT)` directly — eliminating one indirection and making the import the single statement of intent.
Reviews (1): Last reviewed commit: "feat(ai-observability): route eval-repor..." | Re-trigger Greptile |
Call build_openai_chat_client directly for the report agent's LLM client, so it routes through the internal Go ai-gateway when AI_GATEWAY_URL + AI_GATEWAY_API_KEY are set and goes direct to OpenAI otherwise. The Cloud/DEBUG guardrail lives in the shared helper. Default-unset preserves current behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
be4d5e6 to
c696081
Compare
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.
Problem
The eval-report agent built its OpenAI client directly on
OPENAI_API_KEY. Make it routable through the internal Go ai-gateway by env, with no behavior change until flipped.Changes
build_openai_chat_clientdirectly (the shared helper the cluster-labeling agents use): routes through the gateway whenAI_GATEWAY_URL+AI_GATEWAY_API_KEYare set, else direct to OpenAI. The Cloud/DEBUG guard lives in the helper.Rollout
Both vars unset (default) is today's behavior; setting them is the cutover. Two cutover-time items, neither active until then: confirm the gateway routes
gpt-5.2, and drop the posthoganalytics callback (the gateway captures$ai_generationitself, so keeping it would double-capture).Not in this PR
OpenAI summarization migration, stacked on top (#65044).
How did you test this code?
Agent-authored. The routing logic is covered by the helper's suite (
test_llm_endpoint.py); the report-agent graph suite stays green. ruff clean. No manual run.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Built with Claude Code; mirrors the merged cluster-labeling routing change. Skills:
/branch-reviewand/pr-descriptions. Addressed Greptile's review (removed the superfluous_get_llmwrapper, calling the helper directly). Requires human review.