LightAgent icon indicating copy to clipboard operation
LightAgent copied to clipboard

Preserve runtime context across LightSwarm handoffs

Open helloJamest opened this issue 4 months ago • 0 comments

Problem

LightAgent.run() already accepts runtime context such as user_id, metadata, trace, result_format, max_retry, and max_tool_iterations.

The LightSwarm path currently drops most of that context:

  • LightSwarm.run(agent, query, stream=False) only forwards stream.
  • LightAgent._handle_task_transfer() only receives stream.
  • Delegated target agents receive parent_trace_id and run_group_id, but not the caller's user_id, metadata, or trace=True.

This can make delegated runs behave differently from direct agent.run() calls. For example, a user-scoped memory run can hand off to a target agent that falls back to user_id=default_user, and a traced source run may create an untraced target run.

Proposed scope

A small, backward-compatible change:

  • allow LightSwarm.run(..., **run_kwargs) and forward supported LightAgent.run() options;
  • pass relevant runtime context through _handle_task_transfer();
  • keep existing stream behavior unchanged;
  • add regression tests with a fake target agent to assert user_id, metadata, trace, parent_trace_id, and run_group_id propagation.

This would not merge delegated traces into the parent trace automatically. It would only make the existing explicit trace hierarchy and runtime context available across LightSwarm handoffs.

I can send a focused PR for this if the scope looks reasonable.

helloJamest avatar Jul 12 '26 05:07 helloJamest