---
title: "Agent Stream Log"
method: POST
path: "/agent/stream_log"
tags: ["agent"]
---

# Agent Stream Log

`POST /agent/stream_log`

Invoke the runnable stream_log the output.

This endpoint allows to stream the output of the runnable, including
the output of all intermediate steps.

The endpoint uses a server sent event stream to stream the output.

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events

Important: Set the "text/event-stream" media type for request headers if
           not using an existing SDK.

This endpoint uses two different types of events:

* data - for streaming the output of the runnable

    {
        "event": "data",
        "data": {
        ...
        }
    }

* error - for signaling an error in the stream, also ends the stream.

{
    "event": "error",
    "data": {
        "status_code": 500,
        "message": "Internal Server Error"
    }
}

* end - for signaling the end of the stream.

    This helps the client to know when to stop listening for events and
    know that the streaming has ended successfully.

    {
        "event": "end",
    }

## Query parameters

- `config_hash` string

## Request body

- AgentStreamLogRequest
  - `input` LangGraphInput, required
    - `messages` union[], required
      - union
        - AIMessageInput — Message from an AI. An `AIMessage` is returned from a chat model as a response to a prompt. This message represents the output of the model and consists of both the raw output as returned by the model and standardized fields (e.g., tool calls, usage metadata) added by the LangChain framework.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'ai'
          - `name` string, nullable
          - `id` string, nullable
          - `tool_calls` ToolCall[]
            - `name` string, required
            - `args` object, required
            - `id` string, nullable, required
            - `type` 'tool_call'
          - `invalid_tool_calls` InvalidToolCall[]
            - `type` 'invalid_tool_call', required
            - `id` string, nullable, required
            - `name` string, nullable, required
            - `args` string, nullable, required
            - `error` string, nullable, required
            - `index` union
              - …
            - `extras` object
          - `usage_metadata` UsageMetadata — Usage metadata for a message, such as token counts. This is a standard representation of token usage that is consistent across models. Example: ```python { "input_tokens": 350, "output_tokens": 240, "total_tokens": 590, "input_token_details": { "audio": 10, "cache_creation": 200, "cache_read": 100, }, "output_token_details": { "audio": 10, "reasoning": 200, }, } ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform.
            - `input_tokens` integer, required
            - `output_tokens` integer, required
            - `total_tokens` integer, required
            - `input_token_details` InputTokenDetails — Breakdown of input token counts. Does *not* need to sum to full input token count. Does *not* need to have all keys. Example: ```python { "audio": 10, "cache_creation": 200, "cache_read": 100, } ``` May also hold extra provider-specific keys. !!! version-added "Added in `langchain-core` 0.3.9"
              - …
            - `output_token_details` OutputTokenDetails — Breakdown of output token counts. Does *not* need to sum to full output token count. Does *not* need to have all keys. Example: ```python { "audio": 10, "reasoning": 200, } ``` May also hold extra provider-specific keys. !!! version-added "Added in `langchain-core` 0.3.9"
              - …
        - HumanMessage — Message from the user. A `HumanMessage` is a message that is passed in from a user to the model. Example: ```python from langchain_core.messages import HumanMessage, SystemMessage messages = [ SystemMessage(content="You are a helpful assistant! Your name is Bob."), HumanMessage(content="What is your name?"), ] # Instantiate a chat model and invoke it with the messages model = ... print(model.invoke(messages)) ```
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'human'
          - `name` string, nullable
          - `id` string, nullable
        - ChatMessage — Message that can be assigned an arbitrary speaker (i.e. role).
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'chat'
          - `name` string, nullable
          - `id` string, nullable
          - `role` string, required
        - SystemMessage — Message for priming AI behavior. The system message is usually passed in as the first of a sequence of input messages. Example: ```python from langchain_core.messages import HumanMessage, SystemMessage messages = [ SystemMessage(content="You are a helpful assistant! Your name is Bob."), HumanMessage(content="What is your name?"), ] # Define a chat model and invoke it with the messages print(model.invoke(messages)) ```
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'system'
          - `name` string, nullable
          - `id` string, nullable
        - FunctionMessage — Message for passing the result of executing a tool back to a model. `FunctionMessage` are an older version of the `ToolMessage` schema, and do not contain the `tool_call_id` field. The `tool_call_id` field is used to associate the tool call request with the tool call response. Useful in situations where a chat model is able to request multiple tool calls in parallel.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'function'
          - `name` string, required
          - `id` string, nullable
        - ToolMessage — Message for passing the result of executing a tool back to a model. `ToolMessage` objects contain the result of a tool invocation. Typically, the result is encoded inside the `content` field. Example: A `ToolMessage` representing a result of `42` from a tool call with id ```python from langchain_core.messages import ToolMessage ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") ``` Example: A `ToolMessage` where only part of the tool output is sent to the model and the full output is passed in to artifact. ```python from langchain_core.messages import ToolMessage tool_output = { "stdout": "From the graph we can see that the correlation between " "x and y is ...", "stderr": None, "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, } ToolMessage( content=tool_output["stdout"], artifact=tool_output, tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", ) ``` The `tool_call_id` field is used to associate the tool call request with the tool call response. Useful in situations where a chat model is able to request multiple tool calls in parallel.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'tool'
          - `name` string, nullable
          - `id` string, nullable
          - `tool_call_id` string, required
          - `artifact` unknown
          - `status` 'success' | 'error'
        - AIMessageChunkInput — Message chunk from an AI (yielded when streaming).
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'AIMessageChunk'
          - `name` string, nullable
          - `id` string, nullable
          - `tool_calls` ToolCall[]
            - `name` string, required
            - `args` object, required
            - `id` string, nullable, required
            - `type` 'tool_call'
          - `invalid_tool_calls` InvalidToolCall[]
            - `type` 'invalid_tool_call', required
            - `id` string, nullable, required
            - `name` string, nullable, required
            - `args` string, nullable, required
            - `error` string, nullable, required
            - `index` union
              - …
            - `extras` object
          - `usage_metadata` UsageMetadata — Usage metadata for a message, such as token counts. This is a standard representation of token usage that is consistent across models. Example: ```python { "input_tokens": 350, "output_tokens": 240, "total_tokens": 590, "input_token_details": { "audio": 10, "cache_creation": 200, "cache_read": 100, }, "output_token_details": { "audio": 10, "reasoning": 200, }, } ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform.
            - `input_tokens` integer, required
            - `output_tokens` integer, required
            - `total_tokens` integer, required
            - `input_token_details` InputTokenDetails — Breakdown of input token counts. Does *not* need to sum to full input token count. Does *not* need to have all keys. Example: ```python { "audio": 10, "cache_creation": 200, "cache_read": 100, } ``` May also hold extra provider-specific keys. !!! version-added "Added in `langchain-core` 0.3.9"
              - …
            - `output_token_details` OutputTokenDetails — Breakdown of output token counts. Does *not* need to sum to full output token count. Does *not* need to have all keys. Example: ```python { "audio": 10, "reasoning": 200, } ``` May also hold extra provider-specific keys. !!! version-added "Added in `langchain-core` 0.3.9"
              - …
          - `tool_call_chunks` ToolCallChunk[]
            - `name` string, nullable, required
            - `args` string, nullable, required
            - `id` string, nullable, required
            - `index` integer, nullable, required
            - `type` 'tool_call_chunk'
          - `chunk_position` 'last', nullable
        - HumanMessageChunk — Human Message chunk.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'HumanMessageChunk'
          - `name` string, nullable
          - `id` string, nullable
        - ChatMessageChunk — Chat Message chunk.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'ChatMessageChunk'
          - `name` string, nullable
          - `id` string, nullable
          - `role` string, required
        - SystemMessageChunk — System Message chunk.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'SystemMessageChunk'
          - `name` string, nullable
          - `id` string, nullable
        - FunctionMessageChunk — Function Message chunk.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'FunctionMessageChunk'
          - `name` string, required
          - `id` string, nullable
        - ToolMessageChunk — Tool Message chunk.
          - `content` union, required
            - string
            - union[]
              - …
          - `additional_kwargs` object
          - `response_metadata` object
          - `type` 'ToolMessageChunk'
          - `name` string, nullable
          - `id` string, nullable
          - `tool_call_id` string, required
          - `artifact` unknown
          - `status` 'success' | 'error'
  - `config` AgentLangGraphConfig
  - `include_names` string[], nullable — If specified, filter to runnables with matching names
  - `include_types` string[], nullable — If specified, filter to runnables with matching types
  - `include_tags` string[], nullable — If specified, filter to runnables with matching tags
  - `exclude_names` string[], nullable — If specified, exclude runnables with matching names
  - `exclude_types` string[], nullable — If specified, exclude runnables with matching types
  - `exclude_tags` string[], nullable — If specified, exclude runnables with matching tags
  - `kwargs` object

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/datawhalechina/apis/data-agent-backend.md) · [All operations](https://skmtc.dev/datawhalechina/apis/data-agent-backend/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/datawhalechina/data-agent-backend/revisions/0c046ac2b029/schema)
