🚀 Simplify your work by integrating Haufe Copilot via API
Guides

Deep Agent

Event-driven streaming from Deep Agent, exposing typed content blocks.

warning

Deep Agent is currently under development phase.

Deep Agent streams responses as typed content blocks instead of plain text. Each chunk exposes what the agent is doing internally - reasoning, tool calls executed inline, or the final answer - in real time.

info

The events/stream endpoints are dedicated to assistants that stream content_blocks e.g. Deep Agent - streams content_blocks instead of plain text. In addition, what is specific to Deep Agent is the server_tool_call / server_tool_result block pair: Deep Agent executes tools itself within the same turn and reports the trace inline, whereas other assistants that call tools emit a tool_call block and expect the caller to execute it and return the result as a separate tool message.

Endpoints

Deep Agent is available on both the Threads and Chat Completions APIs:

ModeEndpoint
ThreadsPOST /v1/threads/{thread_id}/run/events/stream
Chat CompletionsPOST /v1/chat/completions/events/stream

Both endpoints return the same NDJSON response format (one JSON object per line) with identical content block types. The only difference is how you provide the conversation context — thread ID vs. inline messages.

The request body is identical to the corresponding regular stream endpoint (/run/stream or /chat/completions/stream).

Content Block Types

Each chunk's delta.content_blocks is a list of content blocks. A single chunk typically contains one block.

TypeKey field(s)Description
texttextA fragment of the final answer text.
reasoningreasoningInternal thinking produced before the answer.
tool_callname, args, idA tool invocation the caller must execute and answer with a separate tool message.
server_tool_callname, args, idDeep Agent only. A tool invocation the agent executes itself, inline, within the same turn.
server_tool_resulttool_call_id, status, outputDeep Agent only. The result of a preceding server_tool_call. status is success or error.

Blocks arrive in the order they are produced by the agent.

Response Shape

Each NDJSON line looks like this:

// server_tool_call
{
  "message_id": "969b216f-605f-44f4-9df9-cc43e56326fd",
  "thread_id": "...",
  "created_at": "...",
  "delta": {
    "role": "assistant",
    "content_blocks": [
      {
        "type": "server_tool_call",
        "name": "human_resource_search_tool",
        "args": { "user_query": "wiederholtes Zuspätkommen Abmahnung verhaltensbedingte Kündigung" },
        "id": "call_pjGaby08YGRYEOVdqQtcIYRj"
      }
    ],
    "sources": []
  }
}

// server_tool_result
{
  "message_id": "969b216f-605f-44f4-9df9-cc43e56326fd",
  "thread_id": "...",
  "created_at": "...",
  "delta": {
    "role": "assistant",
    "content_blocks": [
      {
        "type": "server_tool_result",
        "tool_call_id": "call_pjGaby08YGRYEOVdqQtcIYRj",
        "status": "success",
        "output": "<documents><document id=..."
      }
    ],
    "sources": []
  }
}

// reasoning
{
  "message_id": "969b216f-605f-44f4-9df9-cc43e56326fd",
  "thread_id": "...",
  "created_at": "...",
  "delta": {
    "role": "assistant",
    "content_blocks": [
      {
        "type": "reasoning",
        "reasoning": "Searching for specifics about repeated lateness and dismissal..."
      }
    ],
    "sources": []
  }
}

{ "..." }

// text (final answer)
{
  "message_id": "969b216f-605f-44f4-9df9-cc43e56326fd",
  "thread_id": "...",
  "created_at": "...",
  "delta": {
    "role": "assistant",
    "content_blocks": [
      {
        "type": "text",
        "text": "Wenn Sie nicht Arbeitgeber oder kündigungsberechtigte Person sind..."
      }
    ],
    "sources": [
      {
        "content": "§ 622 Abs. 3 BGB: Während einer vereinbarten Probezeit...",
        "meta_data": { "document_title": "Bürgerliches Gesetzbuch (BGB)", "section": "§ 622 Abs. 3" }
      }
    ]
  }
}

Sources are attached to the chunk that finalizes the answer - earlier chunks typically have an empty sources array.

Next Steps

On this page