Agent Teams: TaskUpdate metadata does not persist to disk for background agents
Problem
When an agent is spawned with run_in_background=true and team_name (Agent Teams mode), calls to TaskUpdate(taskId, metadata={...}) do not persist the metadata to the task JSON file on disk.
The task file at ~/.claude/tasks/{team_name}/{taskId}.json retains only the original fields (id, subject, description, activeForm, status, blocks, blockedBy, owner) with no metadata key added after multiple TaskUpdate calls.
This breaks any hooks or workflows that read task metadata from disk (e.g., a hook that checks for required metadata before allowing task completion).
Reproduction
- Create a team and task
- Spawn a background agent:
Task(name="bg-test", team_name="test", subagent_type="general-purpose", run_in_background=true, prompt="...") - Agent calls
TaskUpdate(taskId, status="in_progress", metadata={"key": "value"}) - Check file:
cat ~/.claude/tasks/test/{taskId}.json— nometadatafield present
Expected Behavior
TaskUpdate metadata should persist to the task JSON file regardless of whether the agent runs in foreground or background.
Environment
- Claude Code CLI (terminal mode)
- macOS Darwin 25.4.0
- Agent Teams enabled
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗