{
  "version": "s13",
  "title": "Background Tasks",
  "description": "Long-running work moves to a thread while the agent keeps the main loop responsive.",
  "steps": [
    {
      "type": "user_message",
      "content": "Run a long repository scan and tell me when it finishes.",
      "annotation": "The user asks for work that may exceed the normal foreground loop."
    },
    {
      "type": "assistant_text",
      "content": "I'll start the scan in the background so we can keep the conversation responsive.",
      "annotation": "The model chooses the background path instead of blocking on the tool result."
    },
    {
      "type": "tool_call",
      "toolName": "bash",
      "content": "rg \"TODO|FIXME\" .",
      "toolInput": "{\"background\":true}",
      "annotation": "The tool call is wrapped with a background flag."
    },
    {
      "type": "system_event",
      "content": "background_tasks[task_42] = Thread(target=run_bash)",
      "annotation": "The runtime starts a thread and returns immediately."
    },
    {
      "type": "tool_result",
      "toolName": "bash",
      "content": "Started background task task_42.",
      "annotation": "A placeholder result is appended to the main conversation."
    },
    {
      "type": "system_event",
      "content": "<task_notification id=\"task_42\" status=\"done\">Found 12 matches.</task_notification>",
      "annotation": "The completed thread injects a notification back into the next loop."
    },
    {
      "type": "assistant_text",
      "content": "The scan finished with 12 matches. I'll summarize the most important ones now.",
      "annotation": "The agent consumes the background result as fresh context."
    }
  ]
}
