Skip to content

add name attribute to FunctionBaseConfig for workflow naming in span exporter#1482

Merged
rapids-bot[bot] merged 7 commits intoNVIDIA:release/1.4from
bbednarski9:bb/workflow-naming
Jan 28, 2026
Merged

add name attribute to FunctionBaseConfig for workflow naming in span exporter#1482
rapids-bot[bot] merged 7 commits intoNVIDIA:release/1.4from
bbednarski9:bb/workflow-naming

Conversation

@bbednarski9
Copy link
Contributor

@bbednarski9 bbednarski9 commented Jan 24, 2026

Description

This PR adds the name attribute to FunctionBaseConfig, enabling workflows to be optionally named (non-breaking, backwards compatible). This allows developers to optionally name workflows and have those names carried through the span exporter and represented in OTEL data. This PR follows #1320 which enabled span parent-child lineage for nested tool calls. /examples/observability/simple_calculator_observability/config-phoenix-nested.yml has been updated - showing this working in practice.
Closes
#1335

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features
    • Optional display names for functions and workflows used in tracing and observability, improving monitoring visibility; sensible identifiers are derived automatically when omitted.
  • Refactor
    • Enhanced workflow name-resolution for run and streaming events so observability consistently shows meaningful names (explicit name → instance → type → fallback).
  • Tests
    • Added unit tests validating the new name-resolution behavior for observability events.
  • Chores
    • Disabled a local pre-commit hook.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9 bbednarski9 requested a review from a team as a code owner January 24, 2026 06:38
@bbednarski9 bbednarski9 added improvement Improvement to existing functionality non-breaking Non-breaking change labels Jan 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

Walkthrough

Adds an optional name field to function/workflow configs and updates builder and runner logic to avoid exposing the workflow placeholder by preferring config.name, then instance_name, and finally config.type; includes tests, an example config update, and disables a local pre-commit hook.

Changes

Cohort / File(s) Summary
Observability config
examples/observability/simple_calculator_observability/configs/config-phoenix-nested.yml
Added workflow.name set to power_of_two_agent.
Function schema
src/nat/data_models/function.py
Added optional `name: str
Builder instance naming
src/nat/builder/function.py
Imported WORKFLOW_COMPONENT_NAME; changed instance_name initialization to avoid exposing the workflow placeholder and to prefer config.name or config.type when appropriate.
Runtime name resolution
src/nat/runtime/runner.py
Imported WORKFLOW_COMPONENT_NAME; reworked workflow_name resolution for result and streaming paths to prefer config.name, then instance_name, treat placeholder instance_name by using config.type, and allow None if unresolved.
Tests
tests/nat/runtime/test_runner_trace_ids.py
Added test_runner_workflow_name_resolution to verify resolution across config.name, instance_name, and config.type fallbacks; added test scaffolding and patches; removed an asyncio marker from an existing test.
Pre-commit config
.pre-commit-config.yaml
Commented out the local clear-notebook-output-cells hook, disabling it.
Manifests / Metadata
manifest_file, pyproject.toml, requirements.txt
Minor manifest references noted in summary; no functional manifest edits in the diff.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Config (workflow/function)
    participant Builder as Builder
    participant Runtime as Runner
    participant Tracing as Tracing/Exporter

    Config->>Builder: provide function config (may include `name`)
    Builder->>Builder: determine `instance_name`
    note right of Builder: prefer provided instance_name\nif == WORKFLOW_COMPONENT_NAME use config.name → config.type
    Builder->>Runtime: supply Function with `instance_name` and config
    Runtime->>Runtime: resolve `workflow_name`
    note right of Runtime: prefer config.name → instance_name\nif instance_name == WORKFLOW_COMPONENT_NAME then use config.type\nelse allow None
    Runtime->>Tracing: emit WORKFLOW_START with resolved `workflow_name`
    Runtime->>Tracing: emit WORKFLOW_END with resolved `workflow_name`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a name attribute to FunctionBaseConfig for workflow naming. However, it exceeds the recommended 72-character limit at 77 characters.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/nat/data_models/function.py`:
- Around line 27-38: Update the docstring in the Function configuration class to
wrap code entities in backticks: change occurrences of name and middleware to
`name` and `middleware`, and wrap the literal `middleware` section reference and
`YAML` if mentioned, so all code/config entities are backticked; locate the
docstring above the Field declaration for the name attribute (and the comment
block describing middleware) and apply the backticks consistently for `name`,
`middleware`, and any inline YAML section references.
🧹 Nitpick comments (1)
src/nat/runtime/runner.py (1)

168-180: Deduplicate workflow name resolution logic.

The same fallback chain appears in both result and result_stream. Centralizing it reduces drift and keeps behavior consistent.

♻️ Suggested refactor
 class Runner:
+    def _resolve_workflow_name(self) -> str:
+        """Resolve workflow name with backward-compatible fallback chain."""
+        config = getattr(self._entry_fn, "config", None)
+        workflow_name = getattr(config, "name", None)
+        if not workflow_name:
+            workflow_name = getattr(self._entry_fn, "instance_name", None)
+            if workflow_name == WORKFLOW_COMPONENT_NAME:
+                workflow_name = getattr(config, "type", None) or "workflow"
+            elif not workflow_name:
+                workflow_name = "workflow"
+        return workflow_name
@@
-            config = getattr(self._entry_fn, 'config', None)
-            workflow_name = getattr(config, 'name', None)
-            if not workflow_name:
-                workflow_name = getattr(self._entry_fn, 'instance_name', None)
-                if workflow_name == WORKFLOW_COMPONENT_NAME:
-                    workflow_name = getattr(config, 'type', None) or "workflow"
-                elif not workflow_name:
-                    workflow_name = "workflow"
+            workflow_name = self._resolve_workflow_name()
@@
-            config = getattr(self._entry_fn, 'config', None)
-            workflow_name = getattr(config, 'name', None)
-            if not workflow_name:
-                workflow_name = getattr(self._entry_fn, 'instance_name', None)
-                if workflow_name == WORKFLOW_COMPONENT_NAME:
-                    workflow_name = getattr(config, 'type', None) or "workflow"
-                elif not workflow_name:
-                    workflow_name = "workflow"
+            workflow_name = self._resolve_workflow_name()

Also applies to: 260-272

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Copy link
Member

@willkill07 willkill07 left a comment

Choose a reason for hiding this comment

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

Overall adding name makes sense. Would "display_name" be less likely to conflict with a user's existing configuration?

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9
Copy link
Contributor Author

/ok to test 898d116

@bbednarski9 bbednarski9 reopened this Jan 24, 2026
@bbednarski9
Copy link
Contributor Author

/ok to test 898d116

@bbednarski9 bbednarski9 reopened this Jan 27, 2026
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/nat/runtime/test_runner_trace_ids.py`:
- Line 122: Remove the unnecessary `@pytest.mark.asyncio` decorator from the async
test in tests/nat/runtime/test_runner_trace_ids.py (the test currently annotated
with `@pytest.mark.asyncio`); leave the async def test_... function as-is since
pytest-asyncio auto-detects async tests, and run the test suite to confirm
behavior remains unchanged.

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9
Copy link
Contributor Author

/ok to test 0695894

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9
Copy link
Contributor Author

/ok to test 0b45e99

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/nat/runtime/test_runner_trace_ids.py`:
- Around line 141-145: The unused parameter to_type in the methods convert and
ainvoke should be explicitly marked as intentionally unused to silence Ruff
ARG002; inside each method (convert and ainvoke) add a simple no-op use of the
parameter (e.g., assign it to _ or an unused variable) with a brief comment like
"# silence ruff ARG002" so the signature stays the same but the linter sees the
parameter as used.

@bbednarski9
Copy link
Contributor Author

/ok to test 0b45e99

@bbednarski9
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit fcbc4cd into NVIDIA:release/1.4 Jan 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants