Skip to content

[工作流] Run 21490203690 #179

@github-actions

Description

@github-actions

工作流运行 #21490203690

Task

@WhiteElephantIsNotARobot fix this

Context

{
  "repo": "anomalyco/opencode",
  "event_type": "issue",
  "event_id": "22336521518",
  "trigger_user": "WhiteElephant-abc",
  "issue_number": 11035,
  "issue_body": "### Description\n\nWhen my sessions get complicated and involve many tool calls, it appears that some of them return toolResult payloads that are rejected by AWS/Bedrock (regardless of the model used). \n\nI wish I could give you reproduction steps, but they amount to something like this:\n\n\n\n## Result\nThe streaming consumer is eventually fed an error message\n\n```\n\"error: The format of the value at messages.34.content.0.toolResult.content.0.json is invalid. Provide a json object for the field and try again.\"\n```\n\n## Expected Result\nNot a crash/session-ending event.\n\n## Notes\nI spent some time looking around and found [this issue](https://github.com/aws/aws-sdk-js-v3/issues/7330) with the AWS team. In short, they reject toolResults that have content that is not minimally a JSON object. This looks suspiciously like the error I'm seeing, and I'm wondering if it's an issue we could work around on the client side.\n\n### Plugins\n\nDefaults\n\n### OpenCode version\n\nLatest, from Git.\n\n### Steps to reproduce\n\n## Repro Steps\n- Configure OpenCode to use a local gateway\n- Specify a Bedrock model.\n- Do some workflow that includes tool uses that don't have any obvious return value (file write, db write, who knows exactly).\n- Observe the error above. The server and TUI continue to work, but this session is kaput.\n- Specify e.g. an Azure-hosted model (GPT5, in my case).\n- Observe the issue does not appear.\n\n### Screenshot and/or share link\n\n_No response_\n\n### Operating System\n\nWindows 10 and also MacOS 26.2\n\n### Terminal\n\nPowerShell and also iTerm2",
  "title": "toolResults sent to AWS/Bedrock models rejected for missing json subdocument",
  "comments_history": [
    {
      "id": "IC_kwDOOiiGL87jRg09",
      "user": "github-actions",
      "body": "This issue might be a duplicate of existing issues. Please check:\n- #10259: Compaction fails with Bedrock: toolConfig not included when conversation has tool history (Bedrock validation errors with tool-related content)\n- #8312: Bug: Session corrupted when tool execution is aborted - missing tool_result causes API rejection (Missing or malformed toolResult blocks causing API validation failures)\n\nThese issues both involve toolResult content validation failures with AWS Bedrock and similar providers. Feel free to ignore if your specific case involves a different scenario.",
      "created_at": "2026-01-28T18:18:07Z",
      "type": "comment"
    },
    {
      "id": "IC_kwDOOiiGL87jasV9",
      "user": "jeblackburn-mdb",
      "body": "I added some logging to the server and captured the messages that I believe triggered the error.\n\nGiven an error like this:\n```\n\"error: The format of the value at messages.24.content.0.toolResult.content.0.json is invalid. Provide a json object for the field and try again.\"\n```\n\nI scraped the list of messages being prepared for sending in llm.ts and found that the message that is consistently in the index that matches the error message is the tool-result for todowrite. Here's an example.\n\n\n```\n{'role': 'tool',\n'content': [{'type': 'tool-result',\n   'toolCallId': 'tooluse_RK4WGhiJSAubWcqJyk1WCA',\n   'toolName': 'todowrite',\n   'output': {'type': 'text',\n    'value': '[\\n  {\\n    \"id\": \"1\",\\n    \"content\": \"Create BookJdbcDaoIntegrationTest.java in appropriate test directory\",\\n    \"status\": \"in_progress\",\\n    \"priority\": \"high\"\\n  },\\n  {\\n    \"id\": \"2\",\\n    \"content\": \"Implement test setup with TestContainers Oracle configuration\",\\n    \"status\": \"pending\",\\n    \"priority\": \"high\"\\n  },\\n  {\\n    \"id\": \"3\",\\n    \"content\": \"Write test: verify book not found initially, insert via DA DAO, read via common-service DAO\",\\n    \"status\": \"pending\",\\n    \"priority\": \"high\"\\n  },\\n  {\\n    \"id\": \"4\",\\n    \"content\": \"Write test: verify mergeBookDetails flow (NBOOK + APP_BOOK + TRANSIT)\",\\n    \"status\": \"pending\",\\n    \"priority\": \"high\"\\n  },\\n  {\\n    \"id\": \"5\",\\n    \"content\": \"Write test: verify getNewBookDetails retrieval methods\",\\n    \"status\": \"pending\",\\n    \"priority\": \"medium\"\\n  }\\n]'}}]}\n```\n\nIs it possible that the Bedrock servers are unhappy with \"value\"'s JSON string containing a \"content\" attribute that's a string? I tried and failed to get the agent to send that tool-result as markdown or text instead of JSON, but nope.",
      "created_at": "2026-01-29T04:25:18Z",
      "type": "comment"
    },
    {
      "id": "IC_kwDOOiiGL87jbBJy",
      "user": "jeblackburn-mdb",
      "body": "Confirmed this is the case. It's my assumption that any LLM call made to a Bedrock-hosted model, and includes text that looks like JSON, and includes keywords they think should be structured a certain way, will have this problem.\n\nI confirmed it by hacking the todowrite Tool to return results that are plain text, not JSON.stringify(...) text. I'm not sure if you want to fix this my way (with a more complex serialization of todo list items), or another way, or ignore it altogether. At least we know where the problem lies.",
      "created_at": "2026-01-29T05:05:33Z",
      "type": "comment"
    },
    {
      "id": "IC_kwDOOiiGL87jqThZ",
      "user": "WhiteElephant-abc",
      "body": "@WhiteElephantIsNotARobot fix this",
      "created_at": "2026-01-29T18:32:21Z",
      "type": "comment"
    }
  ],
  "clone_url": "git@github.com:anomalyco/opencode.git",
  "current_comment_id": "IC_kwDOOiiGL87jqThZ",
  "is_mention_in_body": false,
  "is_truncated": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions