-
Notifications
You must be signed in to change notification settings - Fork 170
Description
Environment:
- Agent: Sisyphus (oh-my-opencode)
- Model: Claude Sonnet 4.5
- Tool:
write
Description:
The write tool fails when attempting to write large content (approximately 800+ lines) with a JSON parsing error. The error message is:
invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/path/to/file.md".
Error message: JSON Parse error: Expected '}']
Steps to Reproduce:
- Agent attempts to write a large markdown file (~810 lines) using the
writetool - Tool call is constructed with
filePathandcontentparameters - JSON appears to be truncated or malformed during serialization
- Error is returned indicating missing closing brace
Expected Behavior:
One of the following:
- Accept arbitrarily large content in the
contentparameter - Return a clear error message like "Content exceeds maximum size of X characters/lines"
- Document size limits in the tool's description
Actual Behavior:
Returns confusing JSON parse error that doesn't clearly indicate the root cause is content size.
Workaround:
Use bash tool with heredoc instead of write for large files:
cat >> /path/to/file.md << 'EOF'
[large content here]
EOFThis approach successfully wrote the same 810-line file without errors by chunking the content into multiple bash heredoc operations.
Impact:
- Not critical (workaround exists)
- Affects any use case requiring large file generation (documentation, config files, generated code)
- Error message is misleading - suggests JSON structure issue rather than size limit
Suggested Fix:
- Increase or remove size limit on
contentparameter - If limit is intentional, add validation that returns clear error message before JSON serialization
- Document any size constraints in the tool description
Additional Context:
The same content was successfully written using bash + heredoc, confirming the issue is specific to the write tool's handling of large content, not the underlying file system or content itself.