Skip to content

fix: support legacy gen_ai.prompt/completion attributes for Ollama traces#136

Open
mesutoezdil wants to merge 1 commit intoagentevals-dev:mainfrom
mesutoezdil:fix/legacy-genai-attributes
Open

fix: support legacy gen_ai.prompt/completion attributes for Ollama traces#136
mesutoezdil wants to merge 1 commit intoagentevals-dev:mainfrom
mesutoezdil:fix/legacy-genai-attributes

Conversation

@mesutoezdil
Copy link
Copy Markdown

@mesutoezdil mesutoezdil commented May 5, 2026

Fixes #88

Some instrumentors like opentelemetry-instrumentation-ollama emit flat indexed attributes instead of the gen_ai.input.messages and gen_ai.output.messages JSON arrays that the current code expects:

gen_ai.prompt.0.role = user
gen_ai.prompt.0.content = Hi! Can you help me?
gen_ai.completion.0.role = assistant
gen_ai.completion.0.content = You rolled a 4.

Without a fallback the extraction functions return None for these spans and the conversation is not reconstructed.

Added _parse_legacy_indexed_attrs in extraction.py. It reads the flat attributes by prefix, groups them by index, and returns a message list in the same shape the existing code already handles. The two extraction functions try the standard attributes first and fall through to this only when those are absent. No existing behavior changes.

Five tests cover the new path and verify that standard attributes still win when both are present.

…aces

Instrumentors like opentelemetry-instrumentation-ollama emit flat indexed
attributes instead of the current gen_ai.input.messages JSON arrays.
Without a fallback, user text and agent responses are not extracted from
Ollama traces.

Closes agentevals-dev#88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support legacy GenAI attributes (gen_ai.prompt.*, gen_ai.completion.*)

1 participant