Skip to content

Commit 1cee869

Browse files
authored
Maintain existing functionality for storing run_config in trace context
1 parent b8e064f commit 1cee869

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/agents/run.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,18 @@ async def run(
338338
group_id=run_config.group_id,
339339
metadata=run_config.trace_metadata,
340340
disabled=run_config.tracing_disabled,
341-
):
341+
) as trace_ctx:
342+
if trace_ctx.trace:
343+
# Store run_config in trace context for access by sub-agents
344+
# Prefer storing in metadata if available
345+
if (
346+
hasattr(trace_ctx.trace, "metadata")
347+
and isinstance(trace_ctx.trace.metadata, dict)
348+
):
349+
trace_ctx.trace.metadata["run_config"] = run_config
350+
else:
351+
trace_ctx.trace._run_config = run_config # type: ignore[attr-defined]
352+
342353
current_turn = 0
343354
original_input: str | list[TResponseInputItem] = copy.deepcopy(input)
344355
generated_items: list[RunItem] = []

0 commit comments

Comments
 (0)