Skip to content

Add support for capturing agent tool responses#80

Open
benjichat wants to merge 1 commit intoelevenlabs:mainfrom
benjichat:main
Open

Add support for capturing agent tool responses#80
benjichat wants to merge 1 commit intoelevenlabs:mainfrom
benjichat:main

Conversation

@benjichat
Copy link
Contributor

What's changed

  • Added @published public private(set) var agentToolResponses: [AgentToolResponseEvent] = [] property to Conversation class for tracking agent tool responses
  • Updated the .agentToolResponse event handler to capture and store tool response events
  • Added cleanup logic in resetFlags() and cleanupPreviousConversation() to clear stored responses on reset/disconnect

Why

This extends the previous PR that added support for parsing agent_tool_response events. While the previous PR fixed the parsing errors and handled the events internally, this update exposes the agent tool responses to SDK users through a published property, allowing them to observe and track when agents execute tools.

Usage

SDK users can now observe agent tool executions:

conversation.$agentToolResponses
    .sink { responses in
        for response in responses {
            print("Agent executed tool: \(response.toolName)")
            if response.isError {
                print("Tool execution failed")
            }
        }
    }
    .store(in: &cancellables)

Testing

The existing test coverage for AgentToolResponseEvent parsing validates the underlying functionality. SDK users can now access these events through the published property for their own tracking and debugging needs.

- Add @published property to track agent tool responses
- Update event handler to capture tool response events
- Add cleanup logic in resetFlags() and cleanupPreviousConversation()
- Allows SDK users to observe and track agent tool executions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant