Skip to content

fix(ui): preserve full AgentCore runtime ARN in agent edit form - #39382

Merged
yassin-berriai merged 1 commit into
litellm_internal_stagingfrom
litellm_agent_arn_truncation_fix
Sep 2, 2026
Merged

yassin-berriai merged 1 commit into
litellm_internal_stagingfrom
litellm_agent_arn_truncation_fix

Conversation

@yassin-berriai

@yassin-berriai yassin-berriai commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Editing an AgentCore agent showed a truncated runtime ARN and silently corrupted it on save

How it solves it:

  • Recovers the ARN from the stored model string with a regex instead of matching split("/") segments by position
  • Rejects a malformed or truncated ARN before save with a clear inline error

User Flow

Before: opening an AgentCore agent's settings and saving without any changes corrupts its runtime ARN

  1. Admin opens the Agents page, clicks an AgentCore agent, then "Edit Settings"
  2. The "Agent Runtime ARN" field shows only arn:aws:bedrock-agentcore:eu-central-1:123456789012:runtime, missing everything after runtime/
  3. They click "Save Changes" without editing the field
  4. The agent's stored ARN is now permanently truncated, and calls through this agent fail

After: the same flow shows and saves the complete ARN every time, and a bad value is caught before it can be saved

  1. Admin opens the Agents page, clicks an AgentCore agent, then "Edit Settings"
  2. The "Agent Runtime ARN" field shows the complete ARN, including the resource id after runtime/
  3. They click "Save Changes" without editing the field
  4. Reopening "Edit Settings" shows the identical, complete ARN
  5. If they instead type a truncated or malformed ARN and click "Save Changes", the field shows a validation error and nothing is saved

Relevant issues

Linear ticket

Resolves LIT-6737

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Setup shared across cases: local proxy + Postgres, and the dashboard dev server, both from this branch. An AgentCore agent was created through POST /v1/agents with litellm_params.model set to bedrock/agentcore/arn:aws:bedrock-agentcore:eu-central-1:123456789012:runtime/hosted_agent_4vm3i-BaTdfOELAs, then edited through the Admin UI (Agents -> agent -> Settings -> Edit Settings).

Before (a677242)

Edit form displays and saves the runtime ARN

  1. Open Settings -> Edit Settings for the agent. The "Agent Runtime ARN" field renders truncated, missing the resource id after runtime/:
    Before: truncated ARN field
    Before: full settings form
  2. Click "Save Changes" without editing anything. The toast confirms the save, and GET /v1/agents/{agent_id} now returns the truncated value:
    $ curl -s http://127.0.0.1:16737/v1/agents/071bfa0d-0a38-46ec-9e10-142ce2fe90a9 -H "Authorization: Bearer $MASTER_KEY" | jq -r .litellm_params.model
    bedrock/agentcore/arn:aws:bedrock-agentcore:eu-central-1:123456789012:runtime
    
    The resource id is gone for good and the agent is corrupted

Malformed ARN is rejected before saving

  1. There is no client-side validation on this commit, so the exact same click in the previous case is the "before" for this case too: whatever the field holds, truncated or otherwise, saves silently with no warning

After (443f8df)

Edit form displays and saves the runtime ARN

  1. Open Settings -> Edit Settings for a freshly created agent carrying the same full ARN. The field now renders the complete value:
    After: full ARN field
    After: full settings form
  2. Click "Save Changes" without editing anything. GET /v1/agents/{agent_id} returns the byte-identical full ARN:
    $ curl -s http://127.0.0.1:16737/v1/agents/f3b2207f-88b6-49d3-b841-f65e524424a3 -H "Authorization: Bearer $MASTER_KEY" | jq -r .litellm_params.model
    bedrock/agentcore/arn:aws:bedrock-agentcore:eu-central-1:123456789012:runtime/hosted_agent_4vm3i-BaTdfOELAs
    
  3. Reopening "Edit Settings" shows the same complete ARN, confirming the round trip:
    After: reopened after save

Malformed ARN is rejected before saving

  1. In the same edit form, replace the ARN with a truncated value (arn:aws:bedrock-agentcore:eu-central-1:123456789012:runtime, missing the resource id) and click "Save Changes". The field shows a validation error and the request never goes out:
    After: validation error blocks save
  2. GET /v1/agents/{agent_id} confirms the stored value is unchanged (still the full ARN from the previous case)

Type

🐛 Bug Fix

Caveats

Low

  • The validator checks the overall shape of a Bedrock AgentCore runtime ARN (partition, region, account id, and a non-empty resource id after runtime/); it is not a full ARN grammar validator, matching the acceptance criteria's ask for a lightweight check

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codspeed

codspeed Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_agent_arn_truncation_fix (443f8df) with litellm_internal_staging (987ab76)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (d2fe8af) during the generation of this report, so 987ab76 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@greptile-apps

greptile-apps Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR preserves complete AgentCore runtime ARNs when dynamic agent data is loaded into the edit form and adds client-side ARN validation.

  • Replaces positional path parsing with immutable template-based extraction.
  • Guards malformed server-provided validation patterns so they cannot crash form rendering.
  • Adds backend metadata fields and regression coverage for ARN round trips and validation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; both previously reported issues are resolved at the current head.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_type_utils.ts The immutable split/map parser correctly preserves slash-containing values for all currently configured single-placeholder model templates.
ui/litellm-dashboard/src/app/(dashboard)/agents/_components/dynamic_agent_form_fields.tsx Regex construction is now guarded, fully resolving the prior malformed-pattern render failure while retaining required-field validation.
litellm/proxy/public_endpoints/agent_create_fields.json AgentCore metadata now supplies a valid runtime ARN pattern and actionable validation message.
ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_info.integration.test.tsx Integration tests cover full ARN preservation, truncated ARN rejection, and malformed validation-pattern handling.

Reviews (2): Last reviewed commit: "fix(ui): preserve full AgentCore runtime..." | Re-trigger Greptile

Comment thread ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_type_utils.ts Outdated
parseDynamicAgentForForm recovered a credential field's value from a
stored model string by splitting both the model_template and the model
on "/" and matching by array index. That breaks for any placeholder
value that itself contains "/", such as a Bedrock AgentCore runtime ARN
resource path (runtime/<runtime-id>), silently dropping everything
after the first slash when populating the edit form. Saving without
touching the field then persisted the truncated ARN.

Replace the index-matching split with a non-mutating template parse
(split on the placeholder pattern, escape and rejoin the literal
segments into a regex) so a placeholder captures everything it needs
regardless of embedded slashes. Also add a lightweight ARN-shape
validator for the AgentCore runtime ARN field, guarded against a
malformed pattern string, so a truncated value is rejected client-side
before it reaches the backend.

Resolves LIT-6737
@yassin-berriai
yassin-berriai force-pushed the litellm_agent_arn_truncation_fix branch from ee96243 to 443f8df Compare September 2, 2026 20:03
@yassin-berriai

Copy link
Copy Markdown
Contributor Author

@greptileai please review the current head 443f8df. Addressed both round-1 findings: extractModelTemplateValues now splits on the placeholder pattern instead of mutable accumulators (agent_type_utils.ts), and the validation_pattern regex construction is wrapped in try/catch with a new regression test covering a malformed pattern string (dynamic_agent_form_fields.tsx).

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yassin-berriai
yassin-berriai merged commit 7114302 into litellm_internal_staging Sep 2, 2026
81 checks passed
@yassin-berriai
yassin-berriai deleted the litellm_agent_arn_truncation_fix branch September 2, 2026 20:33
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