Skip to content

feat(libsy): record task_kind and agent_role on the run span - #249

Open
yanyanz89 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
yanyanz89:feature/record-task-kind-and-agent-role-on-run-span
Open

feat(libsy): record task_kind and agent_role on the run span#249
yanyanz89 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
yanyanz89:feature/record-task-kind-and-agent-role-on-run-span

Conversation

@yanyanz89

@yanyanz89 yanyanz89 commented Aug 3, 2026

Copy link
Copy Markdown

What

run_span records session_id, agent_id, task_id, and correlation_id from the request Metadata, but not task_kind or agent_role. This adds them.

Why

Metadata::from_headers already parses both on every request, and they are the only fields describing what kind of work a request is; everything else is an opaque id. Today they are parsed and then dropped before reaching telemetry, so routing behaviour cannot be segmented by work type. #145 noted the same gap on live traffic and left it as a follow-up.

Both have real producers: Codex emits them inside x-codex-turn-metadata, and HEADER_CONFIG already normalizes them.

Span fields only. No metric gains a label, so the bounded-label invariant in docs/internal/metrics_reference.md is unaffected.

Related: #145

How tested

Rust-only change, so the Python gates do not apply.

  • cargo fmt --all -- --check clean
  • cargo clippy -p switchyard-libsy --all-targets -- -D warnings clean
  • cargo test -p switchyard-libsy --test observability green (6 passed)

Extends the existing span assertions in successful_run_records_metrics_spans_and_decision_log. Stashing only the src change while keeping the test fails with left: None, right: Some("code_review"), so the coverage is load-bearing rather than incidentally green.

Checklist

  • One class per file; filename = snake_case of the primary class. — N/A
  • New public symbols exported from switchyard/__init__.py.__all__ if intended for downstream use. — N/A
  • Unit tests added for new components / bug fixes.
  • README / --help updated if customer-facing surface changed. — N/A
  • Commits signed off (Signed-off-by: Your Name <email>) per the DCO.

Notes for reviewers

  • Naming follows the bare-name siblings in the same array rather than the namespaced forms also present on this span. Happy to use an OpenTelemetry semantic-convention name instead.
  • agent_kind left out to keep this to one concern.
  • Touches the same file as feat(observability): add GenAI semantic attributes #224 and is meant to complement it; happy to rebase or defer.

Summary by CodeRabbit

  • New Features
    • Run telemetry now records task type and agent role when available.
    • These fields are included in run spans, improving observability and filtering.

Metadata::from_headers already parses both fields, but run_span drops
them. They are the only fields describing the semantic class of work a
request represents, so routing telemetry cannot be segmented by it.

Span fields only; no metric labels are added and no cardinality
invariant is affected.

Signed-off-by: yanyanz89 <yanyzhang@nvidia.com>
@yanyanz89
yanyanz89 requested a review from a team as a code owner August 3, 2026 15:06
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6a8e0492-9fa7-44ce-8a0b-c6f2bc7f5cdd

📥 Commits

Reviewing files that changed from the base of the PR and between 3acf3d8 and 3278162.

📒 Files selected for processing (2)
  • crates/libsy/src/observability.rs
  • crates/libsy/tests/observability.rs

Walkthrough

The change adds task_kind and agent_role fields to libsy.run spans. Request metadata populates these fields when available. Tests verify the recorded values.

Changes

Observability metadata

Layer / File(s) Summary
Record and verify run metadata
crates/libsy/src/observability.rs, crates/libsy/tests/observability.rs
libsy.run spans now include task_kind and agent_role. Request metadata populates both fields, and tests verify the values.
Estimated code review effort: 1 (Trivial) ~5 minutes

Poem

A rabbit hops through traced-out code,
Two labels join the span’s light load.
“code_review” and “reviewer” appear,
Tests confirm their meaning clear.
Hop, hop—metadata is here!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recording task_kind and agent_role on the run span.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@ayushag-nv
ayushag-nv requested a review from grahamking August 3, 2026 15:13
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.

1 participant