Skip to content

Tool call result metadata lost when retrieving session via server API #1114

@trungutt

Description

@trungutt

Problem

When a tool call completes during streaming, the tool_call_response event includes rich result information:

// pkg/runtime/event.go
type ToolCallResponseEvent struct {
    Type           string                `json:"type"`
    ToolCall       tools.ToolCall        `json:"tool_call"`
    ToolDefinition tools.Tool            `json:"tool_definition"`
    Response       string                `json:"response"`
    Result         *tools.ToolCallResult `json:"result,omitempty"`  // ← Contains isError, meta
    AgentContext
}

// pkg/tools/tools.go
type ToolCallResult struct {
    Output  string `json:"output"`
    IsError bool   `json:"isError,omitempty"`  // ← Lost in REST API
    Meta    any    `json:"meta,omitempty"`     // ← Lost in REST API
}

However, when retrieving a session via GET /sessions/:id, the response only contains chat.Message which stores tool responses as:

// pkg/chat/chat.go - Message struct
Content    string `json:"content"`      // Only the output string
ToolCallID string `json:"tool_call_id"` // Reference to tool call
// No isError field
// No meta field

The example above is for result in tool_call_response. But there are also other attributes as well, such as toolDefinition.

Ideally we should be able to have the same level of information between events vs API

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions