Skip to content

[Bug]: Tool call decorators don't properly serialize args/kwargsΒ #1026

@areibman

Description

@areibman

Contact Details

No response

πŸ“¦ Package Version

0.4.14

🎞️ Framework Version

No response

πŸ”Ž Describe the Bug

When using the @tool decorator, args/kwargs don't get properly serialized. They're getting put as strings:

For example:

 "span_attributes": {
    "agentops": {
      "entity": {
        "input": "{\"args\": [], \"kwargs\": {\"file_path\": \"todo.md\", \"old_str\": \"## Planning & Setup\\n- [x] Analyze requirements for simple HTML todo app\\n- [ ] Create HTML structure with input field and task list\\n- [ ] Add CSS styling for clean, modern appearance\\n- [ ] Implement JavaScript functionality for adding tasks\\n- [ ] Add task completion toggle functionality\\n- [ ] Add task deletion functionality\\n- [ ] Test all features and ensure responsiveness\\n- [ ] Deliver final working app\\n\\n## Features to Include\\n- [ ] Input field for new tasks\\n- [ ] Add button to create tasks\\n- [ ] Task list display\\n- [ ] Mark tasks as complete/incomplete\\n- [ ] Delete individual tasks\\n- [ ] Clean, responsive design\\n- [ ] Local storage persistence (optional enhancement)\", \"new_str\": \"## Planning & Setup\\n- [x] Analyze requirements for simple HTML todo app\\n- [x] Create HTML structure with input field and task list\\n- [x] Add CSS styling for clean, modern appearance\\n- [x] Implement JavaScript functionality for adding tasks\\n- [x] Add task completion toggle functionality\\n- [x] Add task deletion functionality\\n- [x] Test all features and ensure responsiveness\\n- [x] Deliver final working app\\n\\n## Features to Include\\n- [x] Input field for new tasks\\n- [x] Add button to create tasks\\n- [x] Task list display\\n- [x] Mark tasks as complete/incomplete\\n- [x] Delete individual tasks\\n- [x] Clean, responsive design\\n- [x] Local storage persistence (bonus feature added)\"}}",
        "output": "\"ToolResult(success=True, output='Replacement successful.')\""
      },
      "span": {
        "kind": "tool"
      }
    },
    "operation": {
      "name": "str_replace"
    }
  },

The fix is to instead have it be:

 "span_attributes": {
    "agentops": {
      "entity": {
        "input": { "args": [...], "kwargs": {...} } ,
        "output": "..."
      },
      "span": {
        "kind": "tool"
      }
    },
    "operation": {
      "name": "str_replace"
    }
  },

It's ok if the values for args/kwargs are stringified. We only need to serialize the key/value pairs for args+kwargs. Right now input's corresponding value is just a string which is bad

🀝 Contribution

  • Yes, I'd be happy to submit a pull request with these changes.
  • I need some guidance on how to contribute.
  • I'd prefer the AgentOps team to handle this update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions