Skip to content

feat(chat): surface missing-model discovery errors as AgentStartupError#997

Merged
tudormatei1 merged 7 commits into
mainfrom
feat/model-not-found-startup-error
Jul 21, 2026
Merged

feat(chat): surface missing-model discovery errors as AgentStartupError#997
tudormatei1 merged 7 commits into
mainfrom
feat/model-not-found-startup-error

Conversation

@tudormatei1

Copy link
Copy Markdown
Contributor

What & why

When a model name isn't returned by the discovery API, get_model_info raises ModelNotFoundError. Until now get_chat_model let it propagate raw, so the runtime showed an opaque exception instead of an actionable message.

This PR catches ModelNotFoundError and re-raises it as a structured AgentStartupError (code LLM_INVALID_MODEL, category DEPLOYMENT). If a byo_connection_id is set, the message points to the connection's bring-your-own-model config; otherwise it asks you to check the model name and tenant enablement. The original error is preserved as __cause__.

Changes

  • chat/chat_model_factory.py: maps ModelNotFoundError to AgentStartupError. AgentStartupError / UiPathErrorCategory imported lazily inside the except block to avoid a chat -> agent import cycle.
  • pyproject.toml: uipath-llm-client / uipath-langchain-client floors to >=1.17.1,<1.18.0; version to 0.14.11.
  • uv.lock: regenerated (resolves 1.17.1).
  • Tests: TestGetChatModelModelNotFound covers the mapping, BYO variant, and __cause__ chain.

Depends on

uipath-llm-client 1.17.1 (adds ModelNotFoundError + UiPathLLMErrorCode.MODEL_NOT_FOUND). Already published.

Copilot AI review requested due to automatic review settings July 20, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves startup-time error reporting for LLM configuration by converting “model not found in discovery” failures into a structured AgentStartupError (LLM_INVALID_MODEL, category DEPLOYMENT). This aligns the chat-model dispatcher with the agent runtime’s structured error surface so deployments get actionable, user-facing guidance instead of an opaque exception.

Changes:

  • Catch ModelNotFoundError in chat_model_factory.get_chat_model() and re-raise as AgentStartupError, preserving the original exception as __cause__ and tailoring the detail message for BYO connections.
  • Bump uipath-llm-client / uipath-langchain-client floors to >=1.17.1,<1.18.0 and version the package to 0.14.11.
  • Add tests covering the mapping behavior, BYO detail variant, and cause chaining.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
src/uipath_langchain/chat/chat_model_factory.py Maps discovery “missing model” failures to structured startup errors with actionable guidance (including BYO connection messaging) and preserved __cause__.
tests/chat/test_chat_model_factory.py Adds coverage for the error mapping behavior, BYO detail inclusion, and exception cause chaining.
pyproject.toml Updates package version and floors client dependencies to include the new ModelNotFoundError.
uv.lock Regenerates lockfile reflecting the dependency/version bumps.

Comment thread src/uipath_langchain/chat/chat_model_factory.py Outdated
@tudormatei1
tudormatei1 force-pushed the feat/model-not-found-startup-error branch from e9bb399 to 5c60222 Compare July 21, 2026 09:04
Addresses review feedback: the ModelNotFoundError handler imported
AgentStartupError / AgentStartupErrorCode / UiPathErrorCategory lazily
inside the except block to guard against a chat -> agent import cycle.
Verified no such cycle exists (agent.exceptions only depends on
uipath.runtime/uipath.platform, and test_no_circular_imports passes),
so the imports are now at module top-level.
@sonarqubecloud

Copy link
Copy Markdown

@tudormatei1
tudormatei1 merged commit 0706103 into main Jul 21, 2026
45 checks passed
@tudormatei1
tudormatei1 deleted the feat/model-not-found-startup-error branch July 21, 2026 12:28
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.

3 participants