Skip to content

fix(agent): align ixp extraction tool with the job attachment strategy - #1012

Merged
radu-mocanu merged 1 commit into
mainfrom
fix/ixp-extraction-tool-attachment-id
Jul 29, 2026
Merged

fix(agent): align ixp extraction tool with the job attachment strategy#1012
radu-mocanu merged 1 commit into
mainfrom
fix/ixp-extraction-tool-attachment-id

Conversation

@radu-mocanu

@radu-mocanu radu-mocanu commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • the ixp extraction tool now generates its args schema from resource.inputSchema instead of a hardcoded flat model, so it honours the job-attachment $ref that agent builder already writes
  • the tool call resolves job attachments through the shared helper, so the model passes only the attachment id and the full attachment is filled in from state
  • an id that is missing from state is reported back to the model instead of reaching the sdk

Why

the ixp tool was the only attachment-carrying tool not following the shared strategy. it ignored resource.inputSchema entirely, hardcoded an alias-free mirror of Attachment, and typed the id as uuid.UUID.

that last part broke tool simulation: langchain validates arguments against args_schema before invoking the tool, so the tool received a live UUID object rather than the string the model emitted, and anything encoding those kwargs with a plain json.dumps failed with Object of type UUID is not JSON serializable.

process_tool, context_tool, deeprag_tool and analyze_files_tool all generate the schema from the resource, keep the id a string, and convert to uuid.UUID only at the sdk call site. the ixp tool now does the same, which fixes the serialization failure as a side effect of the alignment rather than as a special case.

the arg-resolution half of get_job_attachment_wrapper is extracted as resolve_job_attachment_args so the ixp wrapper can reuse it while keeping its own result handling (tools_storage plus the dataProjection tool message that ixpVsEscalation depends on).

Copilot AI review requested due to automatic review settings July 28, 2026 14:29

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

Adjusts the IXP extraction tool’s attachment id handling so LangChain/Pydantic validation keeps tool kwargs JSON-native (string IDs), while still supporting existing Python callers that may pass uuid.UUID.

Changes:

  • Changed ExtractionToolInputSchema.id from uuid.UUID to str, and added validation/normalization logic.
  • Updated the extraction tool implementation to convert the validated string id to uuid.UUID only at the SDK boundary.
  • Added/updated tests to assert schema alignment with Attachment and to ensure malformed ids fail validation.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/uipath_langchain/agent/tools/extraction_tool.py Switches schema id to str, validates/normalizes it, and converts to uuid.UUID when calling the SDK.
tests/agent/tools/test_extraction_tool.py Extends tests to assert the schema divergence for id, ensure parsed kwargs keep id as str, and invalid ids raise validation errors.
pyproject.toml Bumps project version to 0.14.17.
uv.lock Updates lockfile metadata/version to match the release bump.

Comment thread src/uipath_langchain/agent/tools/extraction_tool.py Outdated
@radu-mocanu
radu-mocanu force-pushed the fix/ixp-extraction-tool-attachment-id branch 4 times, most recently from 67b94ff to 9a7643a Compare July 29, 2026 10:47
@radu-mocanu radu-mocanu changed the title fix(agent): keep ixp extraction tool attachment id a string fix(agent): align ixp extraction tool with the job attachment strategy Jul 29, 2026
@radu-mocanu
radu-mocanu force-pushed the fix/ixp-extraction-tool-attachment-id branch 2 times, most recently from de19bb4 to 3520ec2 Compare July 29, 2026 11:42
Comment thread src/uipath_langchain/agent/tools/extraction_tool.py Outdated
@radu-mocanu
radu-mocanu force-pushed the fix/ixp-extraction-tool-attachment-id branch from 3520ec2 to 86bdf80 Compare July 29, 2026 12:11
Comment on lines +51 to +56
input_model: Any = create_model(resource.input_schema)

@mockable(
name=resource.name,
description=resource.description,
input_schema=ExtractionToolInputSchema.model_json_schema(),
input_schema=input_model.model_json_schema(),

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.

Do we know that deployed agents with IXP tools have been migrated? or that the resource.input_schema had always been populated?

Worried we might break some old agents for which the schema in agent.json was not defined and we relied on the predefined pydantic model

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the schema is always defined in agent builder. however seems like the CLI is scaffolding an empty schema.
added for the time being a fallback inout schema to be back compat

@radu-mocanu
radu-mocanu force-pushed the fix/ixp-extraction-tool-attachment-id branch from 86bdf80 to 6dd26d8 Compare July 29, 2026 12:26
@radu-mocanu
radu-mocanu force-pushed the fix/ixp-extraction-tool-attachment-id branch from 6dd26d8 to aa3bcf1 Compare July 29, 2026 12:44
@radu-mocanu
radu-mocanu enabled auto-merge (squash) July 29, 2026 12:47
@sonarqubecloud

Copy link
Copy Markdown

@radu-mocanu
radu-mocanu merged commit 37011b5 into main Jul 29, 2026
45 checks passed
@radu-mocanu
radu-mocanu deleted the fix/ixp-extraction-tool-attachment-id branch July 29, 2026 12:49
apetraru-uipath added a commit that referenced this pull request Jul 29, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the
ByoValidator shipped in uipath (UiPath/uipath-python#1833):

- Re-export ByoValidator from uipath_langchain.guardrails and the
  .guardrails.decorators shim via a guarded getattr, so the package keeps
  importing (ByoValidator is None) on uipath releases that predate it.
  TODO in-code: switch to a direct import once the dependency floor
  includes it.
- Adapter hardening: the LLM/agent wrappers previously swallowed evaluator
  exceptions silently; they now log a WARNING with the guardrail name and
  traceback (still fail-open). This makes BYOG misconfiguration
  (PROVIDER_ERROR, removed/disabled config, feature flag off) visible.
- Tests: adapter error-logging tests (always run) + ByoValidator-through-
  @guardrail tests (tool / plain function / validator reuse) that skip
  automatically until the installed uipath ships ByoValidator; verified
  passing locally against the uipath-python ByoValidator branch.
- Docs: BYOG section under the decorator pattern in docs/guardrails.md,
  using placeholder validator/connection values and documenting the
  connector-defined `parameters` passthrough.
- Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT
  scope + tool TOOL scope, bindings.json connection binding), with a
  commented-out Azure Content Safety `parameters` example.

Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI).

Independent of the middleware-flavor PR (#1013); branched from main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath added a commit that referenced this pull request Jul 29, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the
ByoValidator shipped in uipath (UiPath/uipath-python#1833):

- Re-export ByoValidator from uipath_langchain.guardrails and the
  .guardrails.decorators shim via a guarded getattr, so the package keeps
  importing (ByoValidator is None) on uipath releases that predate it.
  TODO in-code: switch to a direct import once the dependency floor
  includes it.
- Adapter hardening: the LLM/agent wrappers previously swallowed evaluator
  exceptions silently; they now log a WARNING with the guardrail name and
  traceback (still fail-open). This makes BYOG misconfiguration
  (PROVIDER_ERROR, removed/disabled config, feature flag off) visible.
- Tests: adapter error-logging tests (always run) + ByoValidator-through-
  @guardrail tests (tool / plain function / validator reuse) that skip
  automatically until the installed uipath ships ByoValidator; verified
  passing locally against the uipath-python ByoValidator branch.
- Docs: BYOG section under the decorator pattern in docs/guardrails.md,
  using placeholder validator/connection values and documenting the
  connector-defined `parameters` passthrough.
- Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT
  scope + tool TOOL scope, bindings.json connection binding), with a
  commented-out Azure Content Safety `parameters` example.
- Discovery: docs and sample point at `uip agent guardrails
  byo-configurations` (UiPath/cli#3298) rather than the raw
  agents_/api/designer/byog-guardrails endpoint, and note that the command
  needs an org-admin user session.

Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI).

Independent of the middleware-flavor PR (#1013); branched from main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath added a commit that referenced this pull request Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the
ByoValidator shipped in uipath (UiPath/uipath-python#1833):

- Re-export ByoValidator from uipath_langchain.guardrails and the
  .guardrails.decorators shim via a guarded getattr, so the package keeps
  importing (ByoValidator is None) on uipath releases that predate it.
  TODO in-code: switch to a direct import once the dependency floor
  includes it.
- Adapter hardening: the LLM/agent wrappers previously swallowed evaluator
  exceptions silently; they now log a WARNING with the guardrail name and
  traceback (still fail-open). This makes BYOG misconfiguration
  (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible.
- Tests: adapter error-logging tests (always run) + ByoValidator-through-
  @guardrail tests (tool / plain function / validator reuse) that skip
  automatically until the installed uipath ships ByoValidator; verified
  passing locally against the uipath-python ByoValidator branch.
- Docs: BYOG section under the decorator pattern in docs/guardrails.md,
  using placeholder validator/connection values and documenting the
  connector-defined `parameters` passthrough.
- Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT
  scope + tool TOOL scope, bindings.json connection binding), with a
  commented-out Azure Content Safety `parameters` example.
- Discovery: docs and sample point at `uip agent guardrails list` for the
  validator name, connection id and the connector-defined `Parameters`
  schema, rather than the raw agents_/api/designer/byog-guardrails endpoint.
- Scopes/stages: BYOG validators are not scope- or stage-restricted, so the
  developer chooses; here the scope is inferred from each decorated target.

Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI).

Independent of the middleware-flavor PR (#1013); branched from main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath added a commit that referenced this pull request Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the
ByoValidator shipped in uipath (UiPath/uipath-python#1833):

- Re-export ByoValidator from uipath_langchain.guardrails and the
  .guardrails.decorators shim via a guarded getattr, so the package keeps
  importing (ByoValidator is None) on uipath releases that predate it.
  TODO in-code: switch to a direct import once the dependency floor
  includes it.
- Adapter hardening: the LLM/agent wrappers previously swallowed evaluator
  exceptions silently; they now log a WARNING with the guardrail name and
  traceback (still fail-open). This makes BYOG misconfiguration
  (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible.
- Tests: adapter error-logging tests (always run) + ByoValidator-through-
  @guardrail tests (tool / plain function / validator reuse) that skip
  automatically until the installed uipath ships ByoValidator; verified
  passing locally against the uipath-python ByoValidator branch.
- Docs: BYOG section under the decorator pattern in docs/guardrails.md,
  using placeholder validator/connection values and documenting the
  connector-defined `parameters` passthrough.
- Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT
  scope + tool TOOL scope, bindings.json connection binding), with a
  commented-out Azure Content Safety `parameters` example.
- Discovery: docs and sample point at `uip agent guardrails list` for the
  validator name, connection id and the connector-defined `Parameters`
  schema, rather than the raw agents_/api/designer/byog-guardrails endpoint.
- Scopes/stages: BYOG validators are not scope- or stage-restricted, so the
  developer chooses; here the scope is inferred from each decorated target.

Bump to 0.14.19: 0.14.17 was taken by #1012 and is published on PyPI, and
0.14.18 belongs to the middleware flavor (#1013), which lands first.

Independent of the middleware-flavor PR (#1013); branched from main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath added a commit that referenced this pull request Jul 30, 2026
Add Bring Your Own Guardrail (BYOG) support so coded agents can run
customer-managed validators (a cloud content-safety subscription, a vendor
validation service, or a custom Integration Service connector) configured
under Admin -> AI Trust Layer -> Guardrails Configurations.

- UiPathByoGuardrailMiddleware references the admin configuration by
  validator name + IS connection id and builds a builtInValidator guardrail
  with validator_type="byo" (byoValidatorName/byoConnectionId), reusing the
  shared BuiltInGuardrailMiddlewareMixin hook wiring unchanged.
- validator_parameters is an optional passthrough of raw ValidatorParameter
  values. Scopes and stages are developer-supplied: BYOG validators are not
  scope- or stage-restricted, so all three scopes and both stages are
  available exactly as for the built-in validators.
- Extract BUILT_IN_VALIDATOR_GUARDRAIL_TYPE (Literal-typed, in
  middlewares/_base.py) and use it across all built-in middlewares in place
  of the repeated "builtInValidator" string.
- Docs: "Bring Your Own Guardrail (BYOG)" section in docs/guardrails.md plus
  a "Tuning a BYOG validator" subsection for validator_parameters.
- Sample: samples/joke-agent-bring-your-own-guardrail, guarding AGENT
  (PRE+POST) and TOOL (PRE) scopes, with bindings.json declaring the IS
  connection for per-environment rebinding. All identifiers are placeholders,
  following the bring-your-own-model convention; the Azure Content Safety
  parameter example ships commented out to keep the sample vendor-neutral.
- Discovery: docs and sample point at `uip agent guardrails list` for the
  validator name, connection id and the connector-defined `Parameters`
  schema, rather than the raw agents_/api/designer/byog-guardrails endpoint.
- Bump version to 0.14.18 and sync uv.lock (0.14.17 was taken by #1012 and
  is published on PyPI).

Verified live on alpha against a real BYOG harmful-content configuration:
benign input passes, harmful input blocks at before_agent with the vendor
verdict, and per-category severity thresholds are honoured (omitted blocks
any non-zero severity, 4 lets severity-2 through while blocking 4, 6 lets
both through).

The decorator flavor ships separately (uipath-python ByoValidator + #1014,
which follows at 0.14.19).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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