adk-go icon indicating copy to clipboard operation
adk-go copied to clipboard

Add call_llm span around model invocation for consistency with python ADK

Open supreme-gg-gg opened this issue 8 months ago • 3 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

🔴 Required Information

Is your feature request related to a specific problem?

Go ADK does not emit a call_llm span while the Python ADK does in its base llm flow: https://github.com/google/adk-python/blob/main/src/google/adk/flows/llm_flows/base_llm_flow.py#L1120

For a single agent invocation I expected a trace shape roughly like invoke_agent <agent> -> call_llm -> generate_content <model> where call_llm wraps generate_content. However for Go there are only invoke_agent <agent> and generate_content <model> spans.

Proposed Solution

In internal/llminternal/base_flow.go, callLLM(...) should start a span similar to how generateContent() does.

Additionally, it would be nice if the llm_request / llm_response attributes can be attached on this span. I noticed in Go these contents are emitted as Otel log events, but to stay consistent to Python these data should also be attached as span attributes.

Impact on your work

This makes Go traces less complete than Python traces and removes a natural parent span for model-call-level metadata and parity with the Python ADK tracing model. Also some tracing backends rely on span attributes rather than correlated Otel logs for inspecting model input outputs.


🟡 Recommended Information

Alternatives Considered

A clear and concise description of any alternative solutions or workarounds you've considered.

Willingness to contribute

Are you interested in implementing this feature yourself or submitting a PR?

Proposed API / Implementation

If you have ideas on how this should look in code, please share a pseudo-code example.

Additional Context

Add any other context or screenshots about the feature request.

supreme-gg-gg avatar Apr 02 '26 17:04 supreme-gg-gg

I saw that this is removed in #556 perhaps it's redundant since generate_content now carries all the attributes that used to be on call_llm? Could the maintainer let me know if they would accept adding it back for consistency with Python ADK or it should be kept as is?

supreme-gg-gg avatar Apr 07 '26 00:04 supreme-gg-gg

Hi @dpasiukevich @mazas-google @kdroste-google can you please take a look at this issue? Should we match the Python behavior, or keep it as it is?

indurireddy-TF avatar May 21 '26 07:05 indurireddy-TF

Two separate asks in here, with different answers.

Request/response visibility: addressed by #608, which adds gen_ai.input.messages, gen_ai.output.messages and gen_ai.system_instructions as opt-in attributes on the existing generate_content span, gated on OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. That is the pattern the GenAI conventions define for capturing content, so a backend that reads traces but not logs now sees the prompt and response on the inference span.

The call_llm span: suggesting we don't, having written the patch first and then changed my mind. call_llm isn't in the semconv gen_ai.operation.name registry, and span names SHOULD be {gen_ai.operation.name} {gen_ai.request.model} — so a wrapper ends up tagged generate_content, same as the child it wraps, and anything aggregating by operation double counts.

That does leave a shape difference from Python, so if the ask was parity for its own sake rather than seeing model input and output, worth reopening on those terms.

Closing as covered by #608. Happy to be argued out of it.

jjsasha63 avatar Aug 26 '26 12:08 jjsasha63