Repository navigation
Conversation
…roviders Signed-off-by: aarshx05 <115548002+aarshx05@users.noreply.github.com>
aarshx05
force-pushed
the
fix/chatbot-structured-content
branch
from
October 30, 2026 08:26
4e3e852 to
ccf55cd
Compare
The Newman integration tests were failing because docker compose up -d returns immediately while services are still booting. Added --wait flag so compose blocks until all health checks pass, plus a secondary curl loop to verify the gateway is actually accepting connections on port 30080 before Newman runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011FfMVcQ5F2gnZidb2gtuLU
…an tests" This reverts commit bb26081.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The chatbot assumes an LLM reply's
contentis astr. Newer models (e.g. recent Anthropic Claude models) returncontentas a list of structured content blocks (text / thinking / tool-use / signed text). Inprocess_user_messagethis value is stored in the Mongo chat history and passed toadd_to_chroma_collection→Document(page_content=...), which requires astr. A list therefore raisespydantic.ValidationError; the exception is caught in/genai/askand the raw error is returned to the user and the turn is silently never persisted (chat appears broken and RAG/history storage fails).This bugfix adds a small
message_content_to_text()helper inagent_utils.pythat normalizes any provider'scontentto plain text (joinstextblocks, drops thinking/tool-use blocks, coerces other types safely) and uses it inprocess_user_messagebefore the value is stored, embedded, or returned. No behavior change for providers that already return a string (e.g. OpenAI, older models) — those pass through untouched.Reproduction: run the chatbot with
CHATBOT_LLM_PROVIDER=anthropicand a current Claude model and send a message that elicits a multi-block/signed reply. Before this change the bot returns1 validation error for Document page_content Input should be a valid string [...]; after, it replies normally and the turn persists.Testing
TestMessageContentToTextinservices/chatbot/src/chatbot/tests/test_agent_utils.pycovering: plain-string passthrough, a list of signed text blocks (the crash case), skipping thinking/tool_use blocks, joining multiple and bare-string blocks,None, non-str/list coercion, and the "always returnsstr" contract.cd services/chatbot/src && python -m pytest chatbot/tests/test_agent_utils.py→ all pass.Documentation
No documentation changes required — internal robustness fix, no public API/behavior change.
Checklist: