microsoft / microsoft/amplifier
session_spawner replaces inherited session_metadata wholesale — observability attribution is lost across nested spawns
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 261
- Avg merge
- 3h 28m
- Merged PRs (30d)
- 13
Description
session_spawner.py injects caller-supplied session_metadata into the child session config:
if session_metadata:
...
merged_config["session"]["metadata"] = session_metadata
Because this replaces the inherited value wholesale, any attribution the parent session carried is dropped as soon as a child spawns with its own metadata. Concrete case: the recipe executor (amplifier-bundle-recipes, see microsoft/amplifier-bundle-recipes#80) puts recipe_name/recipe_path/recipe_step into session_metadata so telemetry hooks in the child can attribute per-call cost to the recipe. That works for the recipe's direct agent steps. But when such an agent delegates again, tool-delegate builds fresh metadata containing only agent_name (amplifier-foundation, tool-delegate init.py), and the spawner's wholesale replace erases the recipe attribution — the grandchild's telemetry reports no recipe.
Suggestion: merge instead of replace — keys the caller supplies win, keys it does not supply are inherited from the parent's session.metadata. That keeps the existing contract for callers that set everything, and gives observability consumers stable lineage attribution for free. An alternative is for tool-delegate to copy its parent's metadata into the new dict, but the spawner is the single point every spawn path goes through.
Happy to send a PR if a merge-on-spawn contract is acceptable.
🤖 Generated with Claude Code
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with session_spawner.py and inspect how the child session config inherits session.metadata. Then read tool-delegate init.py and the recipe executor context described in amplifier-bundle-recipes#80; done means caller-provided keys win while inherited recipe attribution survives nested spawns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 74/100