agentops icon indicating copy to clipboard operation
agentops copied to clipboard

Add safe JSON serializa for Agents SDK inputs and outputs

Open Dwij1704 opened this issue 9 months ago • 1 comments

📥 Pull Request

📘 Description

  • Introduced a helper function safe_json_serialize to safely serialize objects to JSON strings.
  • Updated span attribute assignments in AgentsDetailedExporter and AgentsInstrumentor to use this new function for input, output, and final_output attributes, ensuring proper handling of various object types.
  • Removed truncation for agent.instructions to allow full string representation.

🧪 Testing Checked traces and spans via internal tools

Dwij1704 avatar Mar 14 '25 22:03 Dwij1704

we already have an AgentOpsJSONEncoder used in safe_serialize

https://github.com/AgentOps-AI/agentops/tree/main/agentops/helpers/serialization.py#L75

teocns avatar Mar 14 '25 22:03 teocns

Outdated

areibman avatar Mar 18 '25 16:03 areibman