Skip to content

fix: tracing of non-serializable values, e.g. bytes #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2025

Conversation

awsarron
Copy link
Member

@awsarron awsarron commented May 17, 2025

Description

Fixes traces when non-serializable data (like bytes from images, videos, audio, etc.) are present.

Before fixes (output incorrectly shows <replaced>): https://us.cloud.langfuse.com/project/cmaoqkqd901afad07ui6ndt1v/traces/36829363ba6e9f5177322c5edaf3b0fc?timestamp=2025-05-17T17:03:02.274Z&display=details

After fixes (only the image_reader tool output bytes show <replaced>, which is correct): https://us.cloud.langfuse.com/project/cmaoqkqd901afad07ui6ndt1v/traces/0ee3d42598ab472721c884a23caf36fa?timestamp=2025-05-17T21%3A17%3A17.318Z&display=details

Type of Change

  • Bug fix

Testing

  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all
  • hatch run test-integ
  • Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
  • Ran manually with this script:
#!/usr/bin/env python

import logging
import os
from strands import Agent, tool
from strands_tools import calculator, http_request, image_reader

logging.getLogger("strands.telemetry.tracer").setLevel(logging.DEBUG)
logging.basicConfig(
    format="%(levelname)s | %(name)s | %(message)s",
    handlers=[logging.StreamHandler()]
)

os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "Authorization=Basic REDACTED"

agent = Agent(
    system_prompt="You are a helpful assistant that provides concise responses.",
    tools=[http_request, calculator, image_reader],
    trace_attributes={
        "session.id": "abc-1234",
        "user.id": "[email protected]",
        "langfuse.tags": [
            "Agent-SDK",
            "Okatank-Project",
            "Observability-Tags",
        ]
    },
)

agent("Describe the image at /Users/arron/agents-samples/01-getting-started/00-first-agent/images/architecture.png")

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@awsarron awsarron requested a review from a team as a code owner May 17, 2025 21:24
@awsarron awsarron merged commit 2056888 into strands-agents:main May 17, 2025
11 checks passed
@awsarron awsarron deleted the fix-traces-non-serializable branch May 17, 2025 22:58
awsarron added a commit to awsarron/sdk-python that referenced this pull request May 18, 2025
awsarron added a commit that referenced this pull request May 18, 2025
* Update README.md mention of tools repo (#29)

Typo in the examples tools header referencing the wrong repo

* Update README to mention Meta Llama API as a supported model provider (#21)

Co-authored-by: Ryan Coleman <[email protected]>

* fix: tracing of non-serializable values, e.g. bytes (#34)

* fix(bedrock): use the AWS_REGION environment variable for the Bedrock model provider region if set and boto_session is not passed (#39)

* v0.1.2

---------

Co-authored-by: Ryan Coleman <[email protected]>
Co-authored-by: Ryan Coleman <[email protected]>
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.

2 participants