feat(tracing): add base example of inference.net tracing for grc assi…#2926
Open
MJSPollard wants to merge 1 commit into
Open
feat(tracing): add base example of inference.net tracing for grc assi…#2926MJSPollard wants to merge 1 commit into
MJSPollard wants to merge 1 commit into
Conversation
…stant and policy editor agents
|
|
|
@MJSPollard is attempting to deploy a commit to the Comp AI Team on Vercel. A member of the Team first needs to authorize it. |
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.
Hey guys 👋
I know you came to the Inference office and met with Sam and Amar earlier last week and expressed interest in setting up our new tracing product in your platform. We should probably open up a Slack Connect channel to chat more and figure out what the best setup would be for you if you're still interested
This PR is just the bare-minimum example so you can see traces start populating in your Inference dashboard. From there you can use HALO (our open source RLM based agent optimizer) product to ask questions about your traces, derive insights, get recommendations and then iterate on your agent harnesses. We also offer broader observability for the one-shot LLM calls you have all over the platform (questionnaires, embeddings, vendor-risk scraping, evidence forms, etc.) if that's something you'd like to explore. From there you can train your own cheaper/faster models that are fine tuned specifically for the task they are doing.
It's probably best if you test this out yourselves and play around in the Inference dashboard. I noticed your main task automation agent looks like it's closed-source / in a separate enterprise service. This product could be used to improve that too.
I didn't set up a full local version of this repo as I wasn't sure where/if you want to incorporate our tracing and what you want to include in the spans and how you want to group them. I believe it should work but hard to know without full setup and testing. It seemed quicker to just set up an example and hand off to you guys if you're interested in the full setup. If there are any issues just let us know and we can take a look or you can play around with it on your dev server to get it how you want so you can experiment with the results on our dashboard.
Check out our docs if you want to learn more. We also have a cli tool that can assist in adding tracing to any repo.
What does this PR do?
Adds Inference.net Catalyst tracing to the two Vercel AI SDK agents in this repo so the team can see model calls, tool calls, token usage, and errors in the Catalyst dashboard.
Scope (intentionally narrow):
apps/api/src/assistant-chat) — service namecompai-grc-assistantapps/app/src/app/api/policies/[policyId]/chat) — service namecompai-policy-editorOnly these two
streamTextcalls are instrumented. The other ~50 single-shotgenerateText/generateObject/embedcalls (questionnaire, embeddings, vendor risk scraping, evidence forms, etc.) are deliberately left untraced — they're not multi-step agents and can be added later if cost/latency monitoring on those flows becomes useful.What was added:
apps/api/src/inference-tracing.tsandapps/app/src/lib/inference-tracing.ts— small singleton modules that callsetup()from@inference/tracingonce at app boot and expose agetAITelemetry(functionId)helperinitTracing()call inapps/api/src/main.ts(beforeNestFactory.create) and inapps/app/src/instrumentation.ts(Next.js boot hook)experimental_telemetry: getAITelemetry(...)passed on the twostreamTextcallsshutdownTracing()wired into the existing SIGTERM/SIGINT handler inapps/api/src/main.tsto flush the last batch of spans on graceful shutdown (Next.js has no equivalent hook, so apps/app may lose its trailing batch on deploy — acceptable per the canonical Catalyst AI SDK docs).env.examplefiles:CATALYST_OTLP_TOKEN,CATALYST_OTLP_ENDPOINTNot in scope:
The "Automated Evidence" task automation agent — it lives in a separate enterprise service behind
NEXT_PUBLIC_ENTERPRISE_API_URLand can't be instrumented from this repo.Manual
AGENTparent spans withagent.id/session.idattributes. Catalyst's docs suggest this for nicer Agents-dashboard grouping (agent-identity). Skipped here because I couldn't validate async-context propagation through the AI SDK's streaming spans without running the apps. Easy follow-up if the dashboard grouping isn't good enough by default.Fixes #XXXX — N/A
Fixes COMP-XXXX — N/A
Visual Demo
N/A — this is observability wiring with no end-user-visible behavior. Verification happens in the Catalyst dashboard after setting the env vars; see "How should this be tested?" below.
Mandatory Tasks (DO NOT REMOVE)
.env.example.How should this be tested?
Environment variables (set in appropriate places):
Both are documented in
apps/api/.env.exampleandapps/app/.env.example.Steps:
.envfiles. Get the token from the inference dashboard under API Keys.compai-grc-assistantshould showai.streamText,ai.streamText.doStream, andai.toolCallspanscompai-policy-editorshould show the same for the Anthropic-backed policy chatWhat to look for in a healthy trace:
gpt-5for GRC,claude-sonnet-4-6for policy editor)operation.namecontaininggrc-assistantorpolicy-editorIf traces don't appear, just ping or there are any issues just ping us and we can take a look. You can also check https://docs.inference.net/integrations/traces/troubleshooting.
Checklist
(All affirmative bullets removed per the template's instructions.)
Summary by cubic
Add Inference.net Catalyst tracing to the GRC Assistant and Policy Editor agents so you can see model calls, tool usage, token counts, and errors in the Catalyst dashboard. This is a minimal integration to validate tracing before wider coverage.
New Features
streamTextcalls withexperimental_telemetryviagetAITelemetry(...).initTracing()in both apps; addedshutdownTracing()on API shutdown.compai-grc-assistantandcompai-policy-editor.@inference/tracing.Migration
CATALYST_OTLP_TOKENandCATALYST_OTLP_ENDPOINTin both apps’ envs.Written for commit 5ae2d89. Summary will update on new commits. Review in cubic