.agents/skills/llmobs-integration/references/message-extraction.md
Every LLM provider uses a different message format. Before implementing message extraction, you must read the provider's actual source code and existing plugin implementation to understand its specific format.
llm operations pass message objects to tagLLMIO. The tagger defaults a missing role to '' and supports
content, tool-call, tool-result and audio fields; a tool-only message need not carry content.
Embedding, retrieval, workflow, agent, task, step, and tool operations use documents or text values instead.
Common roles: 'user', 'assistant', 'system', 'tool'
Input formats differ in:
messages, contents, prompt, etc.)'model' vs 'assistant')Output formats differ in:
choices[0].message, content[0].text, candidates[0].content.parts, etc.)prompt_tokens/completion_tokens vs input_tokens/output_tokens)Common variations include:
[{role, content}] (e.g. OpenAI)[{type: 'text', text: '...'}])parts array inside a contents array (e.g. Google GenAI)'model' →
'assistant')packages/datadog-plugin-<name>/src/index.js) for argument and result shapesThe best examples of message extraction for the providers we support:
packages/dd-trace/src/llmobs/plugins/anthropic/util.jspackages/dd-trace/src/llmobs/plugins/genai/util.js?? '' or ?? [] when only null / undefined mean
absent, and follow the provider's semantics when an empty value also means absent'model' role to 'assistant' for consistency (preserve 'system', 'tool', 'function')genai/util.js joins text parts with
'\n', anthropic/util.js with ','