OTel: Subagent chat spans after write_agent lose gen_ai.usage.* attributes and report parent model name
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend, observability
Línea de trabajo
Start by tracing how OpenTelemetry spans are created for background subagent turns and how write_agent resumes or steers them; the issue does not name relevant files or tests. Compare span context and model selection with usage-record correlation before and after write_agent. Done means resumed subagent chat spans retain their own invoke_agent parent, model name, and token usage attributes across follow-up turns.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
When a background subagent is launched via task(..., mode: "background", model: "<subagent-model>"), its initial OpenTelemetry spans export normally under an invoke_agent <agent_type> child span with the subagent's gen_ai.request.model and gen_ai.usage.{input_tokens,output_tokens} attributes populated.
However, as soon as the parent session sends a message to that background subagent via write_agent (either waking an idle subagent for a multi-turn follow-up or steering a running subagent), all subsequent OTel chat spans produced by the subagent exhibit two telemetry regressions:
- Wrong model and parent span attribution: Once the initial
invoke_agent <agent_type>span closes, no newinvoke_agentspan is opened for thewrite_agentturn. Subsequent subagentchatandexecute_toolspans attach directly to the parent session's span, and the subagent'schatspans are namedchat <parent-model>withgen_ai.request.model = "<parent-model>"instead of<subagent-model>(even thoughgen_ai.input.messages/gen_ai.output.messageson those spans belong to the subagent). - Missing token usage attributes (
gen_ai.usage.*): Althoughevents.jsonlstill writes completesession.usage_recordentries for the subagent (usage.accounting.sourceSessionId = "<subagent-session-id>",usage.model = "<subagent-model>",inputTokens,outputTokens,cacheReadTokens), the OTel exporter fails to attach usage metrics to those post-write_agentchatspans —gen_ai.usage.input_tokensandgen_ai.usage.output_tokensare completely absent on every subsequent subagentchatspan. Downstream OTel collectors / Prometheusspanmetricspipelines therefore drop 100% of subagent token consumption afterwrite_agent.
Affected version
1.0.115-7 (GitHub Copilot App / copilot-agent)
Steps to reproduce the behavior
- Enable OpenTelemetry trace export (
OTEL_EXPORTER_OTLP_ENDPOINT/ OTLP receiver such as Grafana Alloy + Tempo). - Start a parent session running
<parent-model>(e.g.gemini-4-neon). - Have the parent launch a background subagent running a different
<subagent-model>(e.g.task(agent_type: "general-purpose", mode: "background", model: "gemini-4-hydrogen", ...)). - Observe in Tempo that initial subagent LLM calls appear under
invoke_agent general-purposeaschat gemini-4-hydrogenwithgen_ai.request.model = "gemini-4-hydrogen"andgen_ai.usage.input_tokens/gen_ai.usage.output_tokenspopulated. - Have the parent send a follow-up or steering message via
write_agent(agent_id: "<subagent-id>", message: "...")(reproduces both when the subagent isidlebetween turns and whenrunning). - Inspect the newly exported OTel
chatspans for the subagent's subsequent turns in Tempo:- Span name is
chat gemini-4-neon(gen_ai.request.model = "gemini-4-neon") instead ofgemini-4-hydrogen. gen_ai.usage.input_tokensandgen_ai.usage.output_tokensare missing (null), whileevents.jsonland localassistant_usage_eventsstill record the subagent'sgemini-4-hydrogentoken usage normally.
- Span name is
Expected behavior
After write_agent wakes or steers a background subagent:
- Subsequent subagent turns should be scoped under a subagent
invoke_agentspan (preserving trace hierarchy) and report the subagent's actualgen_ai.request.model(chat <subagent-model>). session.usage_recordevents forsourceSessionId = "<subagent-session-id>"should continue binding to the corresponding subagentchatspans sogen_ai.usage.input_tokens,gen_ai.usage.output_tokens, and cache token attributes remain populated across multi-turnwrite_agentinteractions.
Additional context
- Surface: GitHub Copilot App (
service.name = "github-copilot-app",otel.scope.name = "github.copilot",otel.scope.version = "1.0.115-7") - OS / Arch: macOS (ARM64)
- Root-cause clue from
events.jsonlvs Tempo: Afterwrite_agent, subagentassistant.turn_startevents still reference the originalparentToolCallIdfrom the initialtaskcall (whoseinvoke_agentspan has already closed), whilesession.usage_recordcarriesusage.accounting.sourceSessionId = "<subagent-native-session-id>"andassistant.messagecarriesapiCallId. The OTel span tracker appears to fall back to the parent session's active span/model context and misses the usage-record correlation for subagent turns resumed viawrite_agent.
- Lenguaje dominante
- Python
- Estrellas
- 11.5k
- Forks
- 2k
- Merge medio
- 6 h 34 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/copilot-cli
-
area:plugins
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
github/copilot-cli#5567 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncationAbiertoarea:tools
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
github/copilot-cli#5476 ·
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
github/copilot-cli#5377 ·
-
area:platform-windows area:tools
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
github/copilot-cli#5340 ·
Todos los issues de github/copilot-cli
Issues similares
-
marketing
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Status: Triage Suggestion
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
Los mantenedores suelen responder en 1 día
-
[Suggestion]: NoParrotAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
collabnix/awesome-mcp-lists#515 ·
Los mantenedores suelen responder en 1 día
-
Look-ahead bias via resample('1min').interpolate(method='time') in CCIStrategy and ReinforcedQuickieAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día