feat: Add name and description support to workflows (#1183)

Add optional name and description fields to workflows in both Python and .NET implementations, matching the existing agent API pattern.

Python changes:
- Add name/description parameters to WorkflowBuilder.__init__
- Add name/description attributes to Workflow class
- Include name/description in to_dict() serialization
- Add WORKFLOW_NAME and WORKFLOW_DESCRIPTION OTEL attributes
- Add tests in test_serialization.py and test_workflow_observability.py

.NET changes:
- Add Name and Description properties to Workflow and Workflow<T>
- Add WithName() and WithDescription() fluent methods to WorkflowBuilder
- Add WorkflowName and WorkflowDescription OTEL tags
- Add test in WorkflowBuilderSmokeTests.cs

This enables applications like DevUI to display human-readable workflow names (e.g., 'Data Processing Pipeline') instead of auto-generated UUIDs (e.g., 'Workflow 50fdd917').

Fixes: #1181
This commit is contained in:
Victor Dibia
2025-10-04 08:20:17 -07:00
committed by GitHub
Unverified
parent fd819c6c02
commit 5a7ca13af6
8 changed files with 194 additions and 11 deletions
@@ -599,6 +599,48 @@ class TestSerializationWorkflowClasses:
assert "_shared_state" not in data
assert "_runner" not in data
def test_workflow_name_description_serialization(self) -> None:
"""Test that workflow name and description are serialized correctly."""
# Test 1: With name and description
workflow1 = (
WorkflowBuilder(name="Test Pipeline", description="Test workflow description")
.set_start_executor(SampleExecutor(id="e1"))
.build()
)
assert workflow1.name == "Test Pipeline"
assert workflow1.description == "Test workflow description"
data1 = workflow1.to_dict()
assert data1["name"] == "Test Pipeline"
assert data1["description"] == "Test workflow description"
# Test JSON serialization
json_str1 = workflow1.to_json()
parsed1 = json.loads(json_str1)
assert parsed1["name"] == "Test Pipeline"
assert parsed1["description"] == "Test workflow description"
# Test 2: Without name and description (defaults)
workflow2 = WorkflowBuilder().set_start_executor(SampleExecutor(id="e2")).build()
assert workflow2.name is None
assert workflow2.description is None
data2 = workflow2.to_dict()
assert "name" not in data2 # Should not include None values
assert "description" not in data2
# Test 3: With only name (no description)
workflow3 = WorkflowBuilder(name="Named Only").set_start_executor(SampleExecutor(id="e3")).build()
assert workflow3.name == "Named Only"
assert workflow3.description is None
data3 = workflow3.to_dict()
assert data3["name"] == "Named Only"
assert "description" not in data3
def test_executor_field_validation(self) -> None:
"""Test that Executor field validation works correctly."""
# Valid executor
@@ -282,6 +282,23 @@ async def test_end_to_end_workflow_tracing(span_exporter: InMemorySpanExporter)
assert "build.validation_completed" in build_event_names
assert "build.completed" in build_event_names
# Clear spans to test workflow with name and description
span_exporter.clear()
# Test workflow with name and description - verify OTEL attributes
(
WorkflowBuilder(name="Test Pipeline", description="Test workflow description")
.set_start_executor(MockExecutor("start"))
.build()
)
build_spans_with_metadata = [s for s in span_exporter.get_finished_spans() if s.name == "workflow.build"]
assert len(build_spans_with_metadata) == 1
metadata_build_span = build_spans_with_metadata[0]
assert metadata_build_span.attributes is not None
assert metadata_build_span.attributes.get(OtelAttr.WORKFLOW_NAME) == "Test Pipeline"
assert metadata_build_span.attributes.get(OtelAttr.WORKFLOW_DESCRIPTION) == "Test workflow description"
# Clear spans to separate build from run tracing
span_exporter.clear()