Skip to content

feat(temporal_worker): add optional metrics_headers param to AgentexWorker and get_temporal_client - #500

Closed
alvinkam2001 wants to merge 3 commits into
mainfrom
akam/temporal-metrics-headers
Closed

feat(temporal_worker): add optional metrics_headers param to AgentexWorker and get_temporal_client#500
alvinkam2001 wants to merge 3 commits into
mainfrom
akam/temporal-metrics-headers

Conversation

@alvinkam2001

@alvinkam2001 alvinkam2001 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds authenticated Temporal metrics-export configuration and introduces data-source lineage metadata across ADK, harness, provider, and tracing paths. It also stamps agent versions onto SGP spans.

  • Adds optional metrics_headers forwarding to Temporal OpenTelemetry configuration.
  • Adds public lineage registration, resolution, deduplication, and span-merging APIs.
  • Integrates lineage capture into harness and OpenAI provider spans.
  • Adds AGENT_VERSION to emitted SGP span metadata and expands tracing tests.

Confidence Score: 4/5

The Temporal streaming lineage path should be fixed before merging because it records input tool calls on spans while dropping their registered data-source references.

The new lineage integration passes only response-derived items to the resolver even though the same code separately extracts input function calls, causing those calls to reach the tracing backend without their expected lineage metadata.

Files Needing Attention: src/agentex/lib/core/temporal/plugins/openai_agents/models/temporal_streaming_model.py

Important Files Changed

Filename Overview
src/agentex/lib/core/tracing/lineage.py Introduces the lineage reference model, process-wide registration, item resolution, deduplication, and span-data merging.
src/agentex/lib/core/temporal/plugins/openai_agents/models/temporal_streaming_model.py Adds lineage capture but excludes function calls extracted from input when resolving the completed span's references.
src/agentex/lib/core/temporal/workers/worker.py Adds optional metrics exporter headers and forwards them through worker client initialization.
src/agentex/lib/core/harness/tracer.py Attaches registered lineage references when opening harness tool spans.
src/agentex/lib/core/services/adk/providers/openai.py Reuses serialized run items for span output and lineage resolution across OpenAI service execution paths.
src/agentex/lib/core/tracing/processors/sgp_tracing_processor.py Adds the optional agent deployment version to SGP span metadata.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Tool[Registered tool and data-source refs] --> Registry[Process lineage registry]
  Call[Function-call item] --> Resolver[Resolve and deduplicate refs]
  Registry --> Resolver
  Resolver --> Span[Attach sgp.lineage.refs to span data]
  Span --> Processor[SGP tracing processor]
  Processor --> Backend[Tracing backend]
Loading

Fix all with Greploop Fix All in Cursor Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
### Issue 1
src/agentex/lib/core/temporal/plugins/openai_agents/models/temporal_streaming_model.py:1261
**Input tool lineage is dropped**

When a Temporal model invocation receives a registered `function_call` in its input and the response does not repeat it in `new_items`, lineage resolution examines only `new_items`, causing the span to record the call in `tool_calls` while omitting its registered data-source references.

```suggestion
                    lineage_refs = resolve_refs_from_items([*new_items, *tool_calls])
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "add optional metrics_headers param to Ag..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

stainless-app Bot and others added 3 commits August 14, 2026 02:27
…in span data (#469)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Nitesh Dhanpal <NiteshDhanpal@users.noreply.github.com>
Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

This PR is targeting main, but PRs should target the next branch by default.

The main branch is reserved for release-please and Stainless automation. To resolve, pick one of:

  • Re-target the PR to next (recommended). On the PR page, click Edit next to the title and change the base branch to next.
  • Add the target-main label if this is an intentional exception (e.g. an urgent hotfix). The check will re-run and pass.

See CONTRIBUTING.md for the full branch model.

output_data["tool_outputs"] = tool_outputs

span.output = output_data
lineage_refs = resolve_refs_from_items(new_items)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Input tool lineage is dropped

When a Temporal model invocation receives a registered function_call in its input and the response does not repeat it in new_items, lineage resolution examines only new_items, causing the span to record the call in tool_calls while omitting its registered data-source references.

Suggested change
lineage_refs = resolve_refs_from_items(new_items)
lineage_refs = resolve_refs_from_items([*new_items, *tool_calls])

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agentex/lib/core/temporal/plugins/openai_agents/models/temporal_streaming_model.py
Line: 1261

Comment:
**Input tool lineage is dropped**

When a Temporal model invocation receives a registered `function_call` in its input and the response does not repeat it in `new_items`, lineage resolution examines only `new_items`, causing the span to record the call in `tool_calls` while omitting its registered data-source references.

```suggestion
                    lineage_refs = resolve_refs_from_items([*new_items, *tool_calls])
```

**Knowledge Base Used:**
- [Agent framework integrations](https://app.greptile.com/scale-ai/-/custom-context/knowledge-base/scaleapi/scale-agentex-python/-/docs/agent-framework-integrations.md)
- [Tracing pipeline](https://app.greptile.com/scale-ai/-/custom-context/knowledge-base/scaleapi/scale-agentex-python/-/docs/tracing-pipeline.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

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.

2 participants