Skip to content

[bug] Answer to Bedrock models when streaming is a JSON, not human-readable text #2236

@anionescubd

Description

@anionescubd

Describe the bug
I'm trying to set up tracing using agno. I've successfully managed to set it up for agents that use OpenAI models, but for AWS Bedrock models, when streaming is enabled, the output is not "prettified." Specifically, with streaming enabled, I receive text chunks (as shown in the attached picture). When I disable streaming, the traces look correct and display the actual LLM output as expected, rather than JSON.

To Reproduce
Packages installed:
agno==1.8.1 yfinance==0.2.66 openai==1.92.0 arize-phoenix==11.37.0 openinference-instrumentation-agno==0.1.15 arize-phoenix-otel==0.13.1 opentelemetry-exporter-otlp==1.37.0 openinference-instrumentation-openai==0.1.33 openinference-instrumentation-bedrock==0.1.27 openinference-instrumentation-anthropic==0.1.19

I tested with the following code:

`import asyncio
import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.models.aws import AwsBedrock
from agno.tools.yfinance import YFinanceTools
from phoenix.otel import register
from openinference.instrumentation.agno import AgnoInstrumentor

Configure the Phoenix tracer

tracer_provider = register(
project_name="default",
endpoint="http://127.0.0.1:6006/v1/traces",
auto_instrument=True
)
AgnoInstrumentor().instrument(tracer_provider=tracer_provider)

Create and configure the agent

agent = Agent(
name="Stock Price Agent",
model = AwsBedrock(id="claude-sonnet-4", aws_access_key_id="access key", aws_secret_access_key="secret key"),
tools=[YFinanceTools()],
instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
debug_mode=True,
)

Use the agent

agent.print_response("What is the current price of Tesla?", stream=True)`

Expected behavior
I expected the output of the streaming to be a text with the response, instead of a JSON with text chunks.

Screenshots

Image

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version 24.04.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions