feat(worker): route reviews through the internal fundi gateway, with metadata-only tracing - #24
Merged
Merged
Conversation
… metadata-only tracing The review agent is internal tooling (Nyuchi's own allowlisted repos, team members only), so its inference moves to the `nyuchi-agents` AI Gateway and off the consumer Shamwari gateway. The binding is pre-authenticated, so no gateway token is stored. Cache stays off. - Gateway metadata: worker, job, repo and the trigger KIND — a mention no longer puts the commenter's login in the cost log. - Ask "already reviewed?" before fetching the diff or calling the model, so a webhook redelivery or re-request no longer pays for a review it then discards. A post without a head sha now fails before the model call too. - Workers traces on (100%), and each review is an invoke_agent span with a nested chat span carrying identity, model, diff size and token counts — never the prompt, diff or response. Refs #23 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GHjaH1Vt2dVLWU68iz8tFq
A dynamic route speaks the OpenAI chat-completions shape, so the structured-output request and the answer's location differ from a native Workers AI model. Both are handled, so pointing REVIEW_MODEL at dynamic/review is a one-line var change once the route exists. Refs #23 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GHjaH1Vt2dVLWU68iz8tFq
The owner renamed the internal agents gateway: all agents carry the fundi name, and `nyuchi-agents` was deleted before it carried traffic. A review is an agent run fired by a GitHub event or a team member's mention, so it rides `fundi` — not consumer `shamwari`, not staff chat `nyuchi-ai`. Refs #23 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GHjaH1Vt2dVLWU68iz8tFq
6 tasks
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.
Refs #23
What
The PR-review agent in
worker/(shamwari-github-mcp) is internal tooling — it acts only on Nyuchi's allowlisted repositories, mentions only work for OWNER/MEMBER/COLLABORATOR, MCP callers must be in the Nyuchi org — so its inference moves tofundi, the internal agents gateway (owner: "all agents carry the fundi name"; consumer-triggered in-app AI stays onshamwari, staff chat isnyuchi-ai).AI_GATEWAY_ID = "fundi"; binding is pre-authenticated, no token stored.skipCache: true.{ worker, job: "pr_review", repo, trigger }— the trigger is its kind only, so a GitHub login no longer lands in the cost log. ≤5 scalar entries, no content.REVIEW_ENABLEDkill switch were already in place.REVIEW_MODELmay name a dynamic route (dynamic/review): the code speaks both request shapes. It stays on the direct model until the owner publishes the route.[observability.traces] enabled = true(sampling 1 and persist kept). Custom harness → oneinvoke_agentspan per review with a nestedchatspan; identity attrs (gen_ai.agent.nameshamwari-github-mcp,gen_ai.agent.idshamwari-github-mcp/review,gen_ai.conversation.idrepo#PR) plus counts — no prompts, diffs or responses.cloudflare:workersis imported lazily so Node tests run without a tracer.Validation (in
worker/)npm run build(tsc) — passnpm test— 161/161 passnpx wrangler deploy --dry-run— pass (AI_GATEWAY_ID ("fundi"))🤖 Generated with Claude Code
https://claude.ai/code/session_01GHjaH1Vt2dVLWU68iz8tFq