⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

CLIJSONDecodeError: Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes #98

@nsheff

Description

@nsheff

When using claude code from the CLI, I pass a PDF and it will summarize it just fine.

When doing the same thing using the Python SDK, it gives a JSON buffer error. Here's the code:

# Read PDF
async def main():
    messages: list[Message] = []
    
    async for message in query(
        prompt="Read the PDF document at 'y.pdf' and summarize its content",
        options=ClaudeCodeOptions(max_turns=3, allowed_tools=["Read"])
    ):
        messages.append(message)
    
    print(messages)

result = anyio.run(main)

result

Here's the error:

CLIJSONDecodeError: Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes...

I can call other requests where I'm not asking it to Read a file without issue. I was unable to find any documentation if I'm missing something about reading PDFs from within Python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions