Repository navigation
[2093] feat: Add instrumentation support for openai decision model api's - #438
Open
muhammedrazalak wants to merge 1 commit into
Open
muhammedrazalak wants to merge 1 commit into
muhammedrazalak wants to merge 1 commit into
Conversation
muhammedrazalak
force-pushed
the
feat/decision-api-instrumentation
branch
from
November 13, 2026 08:48
75046d8 to
f39aaf5
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.
Summary
Adds tracing for OpenAI's new Decisions API (
client.decisions.create, sync and async), added in the openai 3.x SDK. Each call now produces anopenai.decisionspan with the input, the questions asked, the typed answers and token usage.Older openai versions without the Decisions API keep working: the instrumentor skips decisions with a DEBUG log, so nothing changes for them.
Changes
netra/instrumentation/libraries/openai/__init__.pyopenai.resources.decisions→Decisions.create/AsyncDecisions.createin a new_instrument_decisions()helper._uninstrument()unwraps both classes. It passes the owning class path (openai.resources.decisions.Decisions,"create"), becauseunwrap(module, "Class.method")silently does nothing.netra/instrumentation/libraries/openai/wrappers.pydecisions_wrapper/adecisions_wrapper. The API has no streaming mode, so each call is a single non-streaming span.openai.decision, kindCLIENT,llm.request.type = "decision".llm.response.duration, time to first token), sets status OK or ERROR (and re-raises), and honours instrumentation suppression.netra/instrumentation/libraries/openai/utils.pyoperation_type == "decision"):input:gen_ai.prompt.0).function_call/custom_tool_call→ assistant entries holding{"name", "arguments"}function_call_output/custom_tool_call_output→toolentriestool_call_idquestions: stored as a JSON array ingen_ai.decision.questions.answers(predicate / choice / score / refusal) are stored ingen_ai.decision.answersand as the span's assistant completion (gen_ai.completion.0), so they show up in the UI like any other model output.tests/test_openai_instrumentation.pyNew span attributes
llm.request.typedecisiongen_ai.decision.questionsgen_ai.decision.answersgen_ai.prompt.*/gen_ai.completion.0.*gen_ai.usage.*Testing
tests/test_openai_instrumentation.py: 69 passed on openai 3.50.0; 68 passed, 1 skipped on openai 2.45.0.openai_decision_apisample in netra-ai-sample-apps runs against the live API and emits anopenai.decisionspan under its workflow span.Notes
_uninstrument()calls for chat, embeddings and responses useunwrap("openai.resources.chat.completions", "Completions.create"), which never removes those wrappers. That should be a follow-up fix.