Skip to content

fix: ixp extraction tool#821

Merged
cristian-groza merged 3 commits intomainfrom
fix/ixp-tool
May 5, 2026
Merged

fix: ixp extraction tool#821
cristian-groza merged 3 commits intomainfrom
fix/ixp-tool

Conversation

@cristian-groza
Copy link
Copy Markdown
Contributor

Summary

Fixes broken IXP extraction tool invocation caused by LangChain's mishandling of pydantic field aliases.

Problem

After PR #796 switched the extraction tool's args_schema to Attachment, tool calls started failing — kwargs.get("id") and kwargs.get("full_name") came back as None, so attachments.download_async was called with key=None.

Two LangChain bugs are at play:

  1. BaseTool._parse_input() extracts each field with getattr(model, alias). When an alias collides with a built-in pydantic model attribute (e.g. schema), this returns the built-in rather than the field value.
  2. tool_call_schema rebuilds a subset of the model field-by-field but drops alias and serialization options, so the rebuilt schema no longer matches what the LLM emits.

Attachment aliases every field (id → ID, full_name → FullName, …), so it hits both bugs.

Fix

Introduce ExtractionToolInputSchema — an alias-free mirror of Attachment with the same python field names and annotations — and use it as the tool's args_schema. Sidesteps both LangChain bugs until they're fixed upstream.

Changes

  • src/uipath_langchain/agent/tools/extraction_tool.py: define ExtractionToolInputSchema and use it as args_schema; docstring explains the reasoning so future readers don't switch back to Attachment.
  • tests/agent/tools/test_extraction_tool.py: replace the args_schema == Attachment assertion with a structural check that the schema's field names and annotations match Attachment.model_fields — guards against drift if
    Attachment evolves.

Test plan

  • uv run pytest tests/agent/tools/test_extraction_tool.py passes
  • Verify end-to-end: deploy an agent that uses the IXP extraction tool and confirm download_async receives the populated UUID

Comment on lines +37 to +44
1. `BaseTool._parse_input()` extracts each field with `getattr(model, key)`,
where `key` is the alias. For aliases that collide with built-in model
attributes (e.g. `schema`), this returns the built-in instead of the
field value, so downstream `kwargs.get("id") / kwargs.get("full_name")`
came back as `None`.
2. `tool_call_schema` rebuilds a subset of the model by copying each field
but drops alias and serialization options, so the rebuilt schema no
longer matches what the LLM emits.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: these bugs are not what causes it. It was us fixing the bugs via our structured tool subclass that surfaced the issue.

@cristian-groza cristian-groza merged commit 7cd4774 into main May 5, 2026
45 checks passed
@cristian-groza cristian-groza deleted the fix/ixp-tool branch May 5, 2026 07:27
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.

2 participants