Weird behavior with Langserve and streaming #174

Closed
opened 2026-02-16 00:19:10 -05:00 by yindo · 2 comments
Owner

Originally created by @zinebbearing on GitHub (May 5, 2024).

This is the endpoint I create with langserve

from main import app as llm_app

add_routes(
    app,
    llm_app.with_types(input_type=Input, output_type=Output),
    path="/api",
)

llm_app is the exact same as https://python.langchain.com/docs/modules/agents/how_to/custom_agent/

when I stream event using llm_app directly, everything works okay (using the same example input as the tutorial). However, when I make the exact same call over /stream_events I get this error from Error code: 400 - {'error': {'message': "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.", 'type': 'invalid_request_error', 'param': 'messages', 'code': None}}

Why?

On side note, streaming the final output token by token is the most important thing. Why is it only possible with event streaming wich is very inconsitant and doesn't work 9/10

Originally created by @zinebbearing on GitHub (May 5, 2024). This is the endpoint I create with langserve from main import app as llm_app ```python add_routes( app, llm_app.with_types(input_type=Input, output_type=Output), path="/api", ) ``` llm_app is the exact same as https://python.langchain.com/docs/modules/agents/how_to/custom_agent/ when I stream event using llm_app directly, everything works okay (using the same example input as the tutorial). However, when I make the exact same call over /stream_events I get this error from Error code: 400 - {'error': {'message': "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.", 'type': 'invalid_request_error', 'param': 'messages', 'code': None}} Why? On side note, streaming the final output token by token is the most important thing. Why is it only possible with event streaming wich is very inconsitant and doesn't work 9/10
yindo closed this issue 2026-02-16 00:19:10 -05:00
Author
Owner

@eyurtsev commented on GitHub (May 6, 2024):

Hi @zinebbearing there's not enough context to provide help. A 4xx indicates that there is error on the user side with formulating the request.

Could you add more information to show what the client code is?

@eyurtsev commented on GitHub (May 6, 2024): Hi @zinebbearing there's not enough context to provide help. A 4xx indicates that there is error on the user side with formulating the request. Could you add more information to show what the client code is?
Author
Owner

@zinebbearing commented on GitHub (May 6, 2024):

Hi @eyurtsev , sorry I actually made a stupid mistake in the code and forgot to close the issue

@zinebbearing commented on GitHub (May 6, 2024): Hi @eyurtsev , sorry I actually made a stupid mistake in the code and forgot to close the issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#174