prompt is too long when replacing in a file. #3521

Closed
opened 2026-02-16 17:40:27 -05:00 by yindo · 1 comment
Owner

Originally created by @nachose on GitHub (Dec 13, 2025).

Description

When trying to get some output into a file, seems like the generated output is too long:

~ Preparing edit...
The edit tool was called with invalid arguments: [
{
"expected": "string",
"code": "invalid_type",
"path": [
"filePath"
],
"message": "Invalid input: expected string, received undefined"
},
{
"expected": "string",
"code": "invalid_type",
"path": [
"oldString"
],
"message": "Invalid input: expected string, received undefined"
},
{
"expected": "string",
"code": "invalid_type",
"path": [
"newString"
],
"message": "Invalid input: expected string, received undefined"
}
].
Please rewrite the input so it satisfies the expected schema.
I need to provide both oldString and newString parameters. Let me fix this error by providing both.
Let me fix the error by providing both oldString and newString parameters in the edit function call.
prompt is too long: 211846 tokens > 200000 maximum

OpenCode version

1.0.151

Steps to reproduce

  1. Ask about some subject (programming generates longer outputs).
  2. Ask to write the results to a file.

Screenshot and/or share link

No response

Operating System

Ubuntu

Terminal

No response

Originally created by @nachose on GitHub (Dec 13, 2025). ### Description When trying to get some output into a file, seems like the generated output is too long: ~ Preparing edit... The edit tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": [ "filePath" ], "message": "Invalid input: expected string, received undefined" }, { "expected": "string", "code": "invalid_type", "path": [ "oldString" ], "message": "Invalid input: expected string, received undefined" }, { "expected": "string", "code": "invalid_type", "path": [ "newString" ], "message": "Invalid input: expected string, received undefined" } ]. Please rewrite the input so it satisfies the expected schema. I need to provide both oldString and newString parameters. Let me fix this error by providing both. Let me fix the error by providing both oldString and newString parameters in the edit function call. prompt is too long: 211846 tokens > 200000 maximum ### OpenCode version 1.0.151 ### Steps to reproduce 1. Ask about some subject (programming generates longer outputs). 2. Ask to write the results to a file. ### Screenshot and/or share link _No response_ ### Operating System Ubuntu ### Terminal _No response_
yindo added the opentuibug labels 2026-02-16 17:40:27 -05:00
yindo closed this issue 2026-02-16 17:40:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 13, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5360: prompt is too long (token limit exceeded)
  • #4845: prompt is too long unrecoverable (with Anthropic Opus 4.5)
  • #3746: Long prompt history stalls the app, long load time
  • #1092: AI_APICallError: prompt is too long

All of these appear to address the same root cause: the prompt context growing too large and exceeding the model's token limit. Your issue specifically mentions this happens when asking the edit tool to replace content in a file when the generated output is too long.

Feel free to ignore if your specific case with file replacement is distinct from these other reports.

@github-actions[bot] commented on GitHub (Dec 13, 2025): This issue might be a duplicate of existing issues. Please check: - #5360: prompt is too long (token limit exceeded) - #4845: prompt is too long unrecoverable (with Anthropic Opus 4.5) - #3746: Long prompt history stalls the app, long load time - #1092: AI_APICallError: prompt is too long All of these appear to address the same root cause: the prompt context growing too large and exceeding the model's token limit. Your issue specifically mentions this happens when asking the edit tool to replace content in a file when the generated output is too long. Feel free to ignore if your specific case with file replacement is distinct from these other reports.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3521