Skip to content

Conversation

nathaliellenaa
Copy link
Contributor

Description

There's an issue when executing ReadFromScratchPadTool or WriteToScratchPadTool with empty parameters through the execute tool API. While these tools should support empty parameter execution, they currently throw an exception:

POST /_plugins/_ml/tools/_execute/ReadFromScratchPadTool
{
  "parameters": {}
}

// Exception thrown
{
    "status": 500,
    "error": {
        "type": "NotSerializableExceptionWrapper",
        "reason": "System Error",
        "details": "unsupported_operation_exception: null"
    }
}

The issue is due to the immutable map implementations being passed to these tools. These tools expect to modify the parameters map during execution (reference). When they attempt to call parameters.put() on an immutable map, an UnsupportedOperationException is thrown.

To fix this issue, we need to ensure these tools always receive a mutable map by creating a mutable copy of the parameters before passing them to the tools. This will allow the tools to modify the parameters as needed during execution, even when starting with empty parameters.

Test with current fix:

POST /_plugins/_ml/tools/_execute/ReadFromScratchPadTool
{
  "parameters": {}
}


// Successful response
{
    "inference_results": [
        {
            "output": [
                {
                    "name": "response",
                    "result": "Scratchpad is empty."
                }
            ]
        }
    ]
}

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 17, 2025 22:16 — with GitHub Actions Inactive
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 17, 2025 22:16 — with GitHub Actions Failure
@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 17, 2025 22:16 — with GitHub Actions Inactive
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 17, 2025 22:16 — with GitHub Actions Error
Copy link
Collaborator

@mingshl mingshl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix makes sense, because scratch pad string is updated through multiple tool use in one agent execution, so it should be mutable parameters in toolExecution.

@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 00:08 — with GitHub Actions Failure
@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 00:08 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.11%. Comparing base (66bcde7) to head (453fbab).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4325      +/-   ##
============================================
- Coverage     80.14%   80.11%   -0.03%     
+ Complexity    10172    10165       -7     
============================================
  Files           854      854              
  Lines         44219    44219              
  Branches       5113     5113              
============================================
- Hits          35440    35427      -13     
- Misses         6630     6639       +9     
- Partials       2149     2153       +4     
Flag Coverage Δ
ml-commons 80.11% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 01:23 — with GitHub Actions Inactive
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 02:47 — with GitHub Actions Failure
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 02:47 — with GitHub Actions Error
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 17:20 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 17:20 — with GitHub Actions Inactive
@ylwu-amzn ylwu-amzn had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 17:20 — with GitHub Actions Failure
@ylwu-amzn ylwu-amzn temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 17:20 — with GitHub Actions Inactive
@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 20:09 — with GitHub Actions Inactive
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 20:09 — with GitHub Actions Failure
@nathaliellenaa nathaliellenaa had a problem deploying to ml-commons-cicd-env-require-approval October 21, 2025 20:09 — with GitHub Actions Failure
@nathaliellenaa nathaliellenaa temporarily deployed to ml-commons-cicd-env-require-approval October 21, 2025 20:09 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants