Skip to content

streamEvents doesn't return response_metadata #8470

@Godrules500

Description

@Godrules500

I'm not sure if this is a bug or my ignorance, but I have this code below where I'm using streamEvents and no matter what I do, response_metadata is always empty. If I do .stream() I can get it, but I'm struggling to still have the response stream to the front (may be a me issue). Is this a bug or is there a way to grab this info?

Essentially what I need to do is stream the data to the client end, and capture once it finishes to inspect things like errors or the finish reason.

const llm = new ChatVertexAI({
      model: 'gemini-2.0-flash-001',
      temperature: 0,
      authOptions: {
        credentials: vertexProviderSettings.googleAuthOptions.credentials,
        projectId: vertexProviderSettings.project!
      },
      location: vertexProviderSettings.location
    })
const agent = createReactAgent({
      llm,
      tools: [],
      /**
       * Modify the stock prompt in the prebuilt agent. See docs
       * for how to customize your agent:
       *
       * https://langchain-ai.github.io/langgraphjs/tutorials/quickstart/
       */
      messageModifier: new SystemMessage(AGENT_SYSTEM_TEMPLATE)
    })
    const eventStream = agent.streamEvents({ messages: body.messages }, { version: 'v2' })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions