-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description
The run_stream() method in ClaudeAgent only processes StreamEvent and ResultMessage types from self._client.receive_response(), but:
-
AssistantMessage is completely ignored - When the Claude SDK returns an
AssistantMessage(which contains the actual response text or error messages), it's silently dropped because there's no handler for it. -
ResultMessage.is_error is never checked - The code only extracts
session_idfromResultMessageand ignores theis_errorflag and error content.
Impact
When an API error occurs (e.g., invalid model name returning 404), the agent returns empty results (result.text = "", result.messages = []) with no exception raised. The error message is buried in an AssistantMessage that gets silently dropped.
Expected Behavior
- Check
ResultMessage.is_errorand raiseServiceExceptionwhen true - Process
AssistantMessageto extract response text or propagate errors - Surface API errors as exceptions instead of returning empty results
Code Sample
# Using invalid model claude-sonnet-4.5
async with ClaudeAgent(default_options={"model": "claude-sonnet-4.5"}) as agent:
response = await agent.run("Hello")
# Returns empty response instead of raising error
print(response.text) # ""Error Messages / Stack Traces
No error is raised - that's the bug. The API returns a 404 error but it's silently ignored.
Package Versions
agent-framework-claude: latest (main branch)
Python Version
Python 3.13
Operating System
macOS