Skip to content

[ENHANCEMENT] Improve Anthropic Vertex Claude completion parsing for non-text content blocks #788

Description

@daewoongoh

Problem (one or two sentences)

Anthropic Vertex Claude completion handling currently assumes the first response content block is the visible text response.

This works for the common case, but it is less resilient if Claude returns an empty content array or includes non-text content blocks before the actual text block.

Context (who is affected and when)

Users using Claude models through Anthropic Vertex may receive responses where the content array contains multiple block types.

For example, a Claude response could include a non-text block before a text block:

[
  { type: "thinking", thinking: "internal reasoning" },
  { type: "text", text: "visible response" },
]

In this case, Zoo Code should still be able to extract the visible text response safely.

Desired behavior (conceptual, not technical)

Zoo Code should handle Anthropic Vertex Claude response content more defensively.

Instead of assuming the first content block is text, it should return the first available text block from the response content array.

If no text block exists, it should safely return an empty string.

Constraints / preferences (optional)

  • Keep the existing behavior unchanged for normal text-only Claude responses.
  • Avoid throwing when the content array is empty.
  • Avoid returning an empty response when a valid text block exists later in the content array.
  • Keep the change small and provider-specific.

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear context and impact

Zoo Code Task Links (optional)

No response

Acceptance criteria (optional)

No response

Proposed approach (optional)

No response

Trade-offs / risks (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions