Skip to content

Conversation

@fvdemand
Copy link

@fvdemand fvdemand commented Dec 15, 2025

In my cloud environment while using v0.71.2

I have continued to have the issue described here.

I have seen it occur both with content_block_delta and content_block_stop.

Somewhat of note I have not got this running locally.

Logs:

Could not parse message into JSON:
From chunk: [ 'event: content_block_delta' ]

I believe this is somewhat normal server behavior when the server is responding for a long time basically the raw string for the sse shows that there is no data. I added a condition to skip this event only when streaming.

@fvdemand fvdemand requested a review from a team as a code owner December 15, 2025 23:47
@felixfbecker
Copy link

@fvdemand sorry to hear you're having issues. It seems like what you're describing is either a bug in our API (in which case we need to fix it there), or a bug in the SSE parsing. I wouldn't expect null data to reach this part of the code, so I'm hesitant to add a workaround here without solving the underlying cause. Do you have an example script that reproduces this issue so we can investigate?

@fvdemand
Copy link
Author

fvdemand commented Dec 16, 2025

I don't have a script that will be useful for you to reproduce. Here is the last bit that gave the error. However, I had the same issue when using the .stream and .finalMessage functions.

const getFullStreamedResponseClaude = async (completionContext) => {
  completionContext = {
    ...completionContext,
    stream: true
  };
  const stream = await anthropicClient.messages.create(completionContext);
  try {
    const chunks = [];
    for await (const chunk of stream) {
      if (chunk.type === 'content_block_delta') {
        const text = chunk.delta?.text || '';
        chunks.push(text);
      }
    }
    return chunks.join('');
  } catch(error) {
    if(error instanceof TypeError) {
      console.log('Type error for stream: ', stream);
    }
    throw error;
  }
};

Do you agree that the log in my original message indicates that the Message code received a sse in which the .raw demonstrates that there is no .data ? For clarity those are not my logs, they come from in the .messages interface.

I will try to get a request ID. Update, I do not have access to the env is there a modification I can make to this block to get the request id?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants