feat(agent): forward model settings and recover from thinking stalls [PC-4672] - #1017
Open
tudormatei1 wants to merge 8 commits into
Open
feat(agent): forward model settings and recover from thinking stalls [PC-4672]#1017tudormatei1 wants to merge 8 commits into
tudormatei1 wants to merge 8 commits into
Conversation
tudormatei1
marked this pull request as ready for review
August 18, 2026 07:42
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR improves agent/tool-call reliability under Anthropic “thinking” modes across transports, adds safer provider HTTP error normalization, and introduces model_settings forwarding for the new chat model factory path.
Changes:
- Add shared “thinking” utilities and Bedrock handler logic to downgrade forced tool-choice when thinking is active, plus a forced-extraction retry path in the ReAct LLM node.
- Refactor ReAct routing/stall accounting from router-level “thinking message limits” to LLM-node stall handling, with new/updated tests.
- Add
model_settingsparameter toget_chat_model, warn when ignored on legacy clients, and bumpuipath-langchain-clientdependency.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/uipath_langchain/chat/thinking.py |
Introduces shared helpers for detecting/stripping thinking and reasoning blocks. |
src/uipath_langchain/chat/handlers/bedrock.py |
Uses shared predicate to downgrade forced tool choice under thinking on Bedrock. |
src/uipath_langchain/chat/chat_model_factory.py |
Adds model_settings arg, forwards to new factory, warns on legacy path. |
src/uipath_langchain/agent/react/llm_node.py |
Moves stall handling into LLM node; adds forced-extraction retry and deterministic failure. |
src/uipath_langchain/agent/react/router.py |
Removes thinking-limit enforcement; routes tool-less content back to agent. |
src/uipath_langchain/agent/react/utils.py |
Renames & documents stall counter as “tool-less turns”. |
src/uipath_langchain/agent/react/forced_extraction.py |
New helper to strip thinking + reasoning blocks and append trailing user turn. |
src/uipath_langchain/agent/exceptions/llm.py |
Consolidates provider HTTP error mapping and adds category/status handling. |
src/uipath_langchain/agent/exceptions/licensing.py |
Removes legacy provider HTTP error mapping module. |
tests/... |
Adds/updates tests for model_settings dispatch, Bedrock downgrade behavior, forced extraction, routing changes, and HTTP error redaction. |
pyproject.toml |
Version bump and dependency range bump for uipath-langchain-client. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…block with response in text
tudormatei1
force-pushed
the
feat/model-specific-settings
branch
from
August 18, 2026 10:12
29cce8a to
9b88d18
Compare
|
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.


Anthropic won't honor a forced
tool_choicewhile extended or adaptive thinking is on, so a thinking model can answer in plain text and never callend_execution. The old consecutive-thinking counter turned that into a hardTHINKING_LIMIT_EXCEEDEDon the first occurrence. Now one tool-less turn is tolerated and retried with thinking off and the tool call forced (react/forced_extraction.py), which every provider honors; only a second stall fails, with the same error code.Stall accounting moved out of the router and into the LLM node, because the router can't tell whether forcing actually survived on the wire — the Bedrock handlers silently downgrade
any->autounder thinking. A tool-less turn with content now always loops back to the agent.AgentGraphConfig.thinking_messages_limitis no longer read anywhere; I left the field in place so existingagent.jsonfiles don't break, but it's dead — say the word if you'd rather deprecate it properly.New
chat/thinking.pyholds the transport-specific knowledge in one place (nativethinkingattribute,model_kwargsfor Bedrock Invoke,additional_model_request_fieldsfor Converse) so the payload handlers and the ReAct loop stop each reimplementing it. Replaying reasoning blocks on a thinking-off call 400s, so the extraction retry strips them and appends a user turn if the history ends on an AI message.Two smaller things ride along.
get_chat_modelgains amodel_settingspassthrough for the client-side work in uipath-langchain-client 1.18.0 (dependency bumped), with a warning when the legacy clients would silently drop it. Andexceptions/licensing.pyfolded intoexceptions/llm.py: provider HTTP errors are now re-raised withfrom Noneand only the gatewaydetail, since the vendor's passthrough message can echo request content and shouldn't reach the run record or App Insights; 5xx also categorizes as SYSTEM instead of UNKNOWN.Verified with the 184 tests across the touched files.