8000 [BUG] Tool spec normalization · Issue #124 · strands-agents/sdk-python · GitHub
[go: up one dir, main page]

Skip to content

[BUG] Tool spec normalization #124

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

Closed
3 tasks done
awsarron opened this issue May 27, 2025 · 0 comments · Fixed by #133
Closed
3 tasks done

[BUG] Tool spec normalization #124

awsarron opened this issue May 27, 2025 · 0 comments · Fixed by #133
Assignees
Labels
bug Something isn't working

Comments

@awsarron
Copy link
Member
awsarron commented May 27, 2025

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.1.5

Python Version

3.13.3

Operating System

macOS

Installation Method

pip

Steps to Reproduce

  1. Create a module tool with TOOL_SPEC defined. In the tool spec, include deeply nested objects.
  2. Create an agent with the tool and check its tool configuration after tool loading:
from strands import Agent
from my_tools import test_nested_tool

agent = Agent(tools=[test_nested_tool])
print(agent.tool_config)

Expected Behavior

Expected loaded tools with deeply nested objects in the tool spec to preserve the nesting.

Actual Behavior

Deeply nested object structures are not preserved, leading to context loss in the specification provided to the model during inference.

Additional Context

Example provided tool spec:

{
    "name": "generate_income_assessment",
    "description": "Generate an income assessment report",
    "inputSchema": {
        "json": {
            "type": "object",
            "required": [
                "application_id",
                "assessment_type",
                "assessment_criteria"
            ],
            "properties": {
                "application_id": {
                    "type": "string",
                    "description": "The ID of the application being assessed"
                },
                "assessment_type": {
                    "type": "string",
                    "description": "Type of assessment being performed",
                    "const": "INCOME"
                },
                "assessment_criteria": {
                    "type": "object",
                    "required": [
                        "verify_application_document",
                        "verify_payslip_document", 
                        "verify_bank_statements",
                        "verify_employer_matches",
                        "verify_salary_matches"
                    ],
                    "properties": {
                        "verify_application_document": {
                            "type": "object",
                            "properties": {
                                "question": { 
                                    "const": "Verify application document is present",
                                    "description": "A specific evaluation criteria that must be assessed as part of the income verification process"
                                },
                                "result": { 
                                    "type": "string",
                                    "enum": ["PASS", "FAIL", "UNKNOWN"],
                                    "description": "The outcome of the assessment check: PASS indicates criteria are met, FAIL indicates criteria are not met, or UNKNOWN if insufficient information is available"
                                },
                                "explanation": { 
                                    "type": "string",
                                    "description": "A concise justification supporting the result, including evidence and reasoning"
                                }
                            },
                            "required": ["question", "result", "explanation"]
                        },
                        "verify_payslip_document": {
                            "type": "object",
                            "properties": {
                                "question": { 
                                    "const": "Verify payslip document is present",
                                    "description": "A specific evaluation criteria that must be assessed as part of the income verification process"
                                },
                                "result": { 
                                    "type": "string",
                                    "enum": ["PASS", "FAIL", "UNKNOWN"],
                                    "description": "The outcome of the assessment check: PASS indicates criteria are met, FAIL indicates criteria are not met, or UNKNOWN if insufficient information is available"
                                },
                                "explanation": { 
                                    "type": "string",
                                    "description": "A concise justification supporting the result, including evidence and reasoning"
                                }
                            },
                            "required": ["question", "result", "explanation"]
                        },
                        "verify_bank_statements": {
                            "type": "object",
                            "properties": {
                                "question": { 
                                    "const": "Verify bank statements are present",
                                    "description": "A specific evaluation criteria that must be assessed as part of the income verification process"
                                },
                                "result": { 
                                    "type": "string",
                                    "enum": ["PASS", "FAIL", "UNKNOWN"],
                                    "description": "The outcome of the assessment check: PASS indicates criteria are met, FAIL indicates criteria are not met, or UNKNOWN if insufficient information is available"
                                },
                                "explanation": { 
                                    "type": "string",
                                    "description": "A concise justification supporting the result, including evidence and reasoning"
                                }
                            },
                            "required": ["question", "result", "explanation"]
                        },
                        "verify_employer_matches": {
                            "type": "object", 
                            "properties": {
                                "question": { 
                                    "const": "Verify employer matches across documents",
                                    "description": "A specific evaluation criteria that must be assessed as part of the income verification process"
                                },
                                "result": { 
                                    "type": "string",
                                    "enum": ["PASS", "FAIL", "UNKNOWN"],
                                    "description": "The outcome of the assessment check: PASS indicates criteria are met, FAIL indicates criteria are not met, or UNKNOWN if insufficient information is available"
                                },
                                "explanation": { 
                                    "type": "string",
                                    "description": "A concise justification supporting the result, including evidence and reasoning"
                                }
                            },
                            "required": ["question", "result", "explanation"]
                        },
                        "verify_salary_matches": {
                            "type": "object",
                            "properties": {
                                "question": { 
                                    "const": "Verify salary matches payslip",
                                    "description": "A specific evaluation criteria that must be assessed as part of the income verification process"
                                },
                                "result": { 
                                    "type": "string",
                                    "enum": ["PASS", "FAIL", "UNKNOWN"],
                                    "description": "The outcome of the assessment check: PASS indicates criteria are met, FAIL indicates criteria are not met, or UNKNOWN if insufficient information is available"
                                },
                                "explanation": { 
                                    "type": "string",
                                    "description": "A concise justification supporting the result, including evidence and reasoning"
                                }
                            },
                            "required": ["question", "result", "explanation"]
                        }
                    },
                    "additionalProperties": False
                }
            }
        }
    }
}

After normalization:

{
  "toolSpec": {
    "name": "generate_income_assessment",
    "description": "Generate an income assessment report",
    "inputSchema": {
      "json": {
        "type": "object",
        "properties": {
          "application_id": {
            "type": "string",
            "description": "The ID of the application being assessed"
          },
          "assessment_type": {
            "type": "string",
            "description": "Type of assessment being performed"
          },
          "assessment_criteria": {
            "type": "object",
            "description": "Property assessment_criteria"
          }
        },
        "required": [
          "application_id",
          "assessment_type",
          "assessment_criteria"
        ]
      }
    }
  }
}

Possible Solution

Fix tool spec normalization to preserve deeply nested objects.

Related Issues

No response

@awsarron awsarron added the bug Something isn't working label May 27, 2025
@yonib05 yonib05 linked a pull request May 28, 2025 that will close this issue
6 tasks
@jer96 jer96 closed this as completed in #133 Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0