Skip to content

Add backend timeout configuration for llm providers and mcp proxy - #1328

Merged
menakaj merged 7 commits into
wso2:mainfrom
menakaj:main
Aug 9, 2026
Merged

Add backend timeout configuration for llm providers and mcp proxy#1328
menakaj merged 7 commits into
wso2:mainfrom
menakaj:main

Conversation

@menakaj

@menakaj menakaj commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

This should be merged after upgrading to the latest gateway. (1.2.0)

Resolves #828

LLM Service provide resiliency configuration

Screenshot 2026-08-08 at 18 05 32

Agent Level llm configuration

Screenshot 2026-08-08 at 18 05 21

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features
    • Added configurable request and idle timeouts for LLM providers, LLM proxies, and MCP endpoints.
    • Added UI controls, duration validation, and deployment/API support for resilience settings.
    • MCP deployments can now use either an upstream URL or reference.
  • Bug Fixes
    • Preserve existing resilience settings when updates omit them.
    • Apply derived defaults while honoring explicit proxy settings.
    • Improved handling of missing proxy records.
  • Tests / Documentation
    • Added coverage for validation, defaults, and deployment output.
    • Updated API documentation and models.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds configurable request and idle timeouts for LLM providers, LLM proxies, MCP endpoints, and agent environments. The change updates API contracts, validation, persistence, deployment generation, console forms, configuration propagation, and missing-record error handling.

Changes

Resilience timeout configuration

Layer / File(s) Summary
Resilience contracts and conversion
agent-manager-service/docs/..., agent-manager-service/models/*, agent-manager-service/spec/*, agent-manager-service/utils/spec_converter.go, console/workspaces/libs/types/src/api/*
Adds optional timeout fields, duration validation, generated API models, TypeScript types, OpenAPI schemas, and bidirectional conversion.
Console resilience configuration
console/workspaces/libs/shared-component/*, console/workspaces/pages/llm-providers/*, console/workspaces/pages/mcp-proxies/*, console/workspaces/pages/configure-agent/*
Adds shared timeout inputs, validation, state handling, dirty-state tracking, and conditional request payloads.
Backend validation and deployment propagation
agent-manager-service/controllers/*, agent-manager-service/services/agent_configuration_service.go, agent-manager-service/services/agent_manager.go, agent-manager-service/services/llm_*, agent-manager-service/services/mcp_proxy_*
Validates resilience values, preserves omitted provider settings, propagates environment and endpoint values, and emits deployment YAML.
Lookup and mapping corrections
agent-manager-service/repositories/*, agent-manager-service/services/gateway_internal_service.go, agent-manager-service/services/llm_proxy_apikey_service.go, agent-manager-service/services/llm_proxy_deployment_service.go
Shares LLM proxy handle backfill logic and maps missing proxy records to utils.ErrLLMProxyNotFound.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • wso2/agent-manager#1513: It contains related shared LLM proxy handle backfilling changes in the same repository functions.

Suggested reviewers: oshanath, hanzjk, rasika2012

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes MCP proxy support, agent-configuration changes, and unrelated not-found and backfill changes beyond issue #828's LLM provider timeout requirement. Remove or split unrelated MCP proxy, error-handling, and backfill changes unless separate linked requirements justify them.
Docstring Coverage ⚠️ Warning Docstring coverage is 72.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description states the purpose and linked issue but leaves most required template sections incomplete or unchanged. Complete the Goals, Approach, user stories, release note, documentation, testing, security, migration, environment, and other required sections.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements configurable LLM provider request and idle timeouts, including UI, API, validation, persistence, and deployment propagation for issue #828.
Title check ✅ Passed The title clearly summarizes the primary change: backend timeout configuration for LLM providers and MCP proxies.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent-manager-service/services/mcp_proxy_deployment.go`:
- Around line 459-476: Update the Main upstream extraction in the deployment
generation flow to copy main.Ref into upstream.Ref alongside the existing URL
mapping. Revise the validation error to state that either an upstream URL or Ref
is required, preserving the existing acceptance of either field.

In `@console/workspaces/pages/llm-providers/src/form/schema.ts`:
- Line 21: Update the duration validation regex used by DURATION_PATTERN in
console/workspaces/pages/llm-providers/src/form/schema.ts at lines 21-21 to
accept optional fractional values while preserving the existing units. Apply the
same regex change in
console/workspaces/pages/mcp-proxies/src/subComponents/EndpointFormFields.tsx at
lines 87-88, and reuse an exported shared constant if appropriate to avoid
duplication.

In
`@console/workspaces/pages/mcp-proxies/src/subComponents/MCPProxyConnectionTab.tsx`:
- Around line 48-49: Update the DURATION_PATTERN validation regex in
MCPProxyConnectionTab to accept an optional decimal fraction before the existing
ms, s, m, or h units, while preserving validation of integer durations and
rejecting malformed values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb9bb7f4-7753-492a-bc64-b535cbea0420

📥 Commits

Reviewing files that changed from the base of the PR and between 2541eba and e46bd79.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (39)
  • agent-manager-service/controllers/llm_controller.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/llm_provider.go
  • agent-manager-service/models/llm_proxy.go
  • agent-manager-service/models/mcp_proxy.go
  • agent-manager-service/models/upstream.go
  • agent-manager-service/models/upstream_test.go
  • agent-manager-service/repositories/agent_configuration_repository.go
  • agent-manager-service/repositories/env_agent_model_mapping_repository.go
  • agent-manager-service/services/agent_configuration_service.go
  • agent-manager-service/services/gateway_internal_service.go
  • agent-manager-service/services/llm_deployment_service.go
  • agent-manager-service/services/llm_deployment_service_test.go
  • agent-manager-service/services/llm_provider_service.go
  • agent-manager-service/services/llm_proxy_apikey_service.go
  • agent-manager-service/services/llm_proxy_deployment_service.go
  • agent-manager-service/services/llm_proxy_deployment_service_test.go
  • agent-manager-service/services/llm_proxy_service.go
  • agent-manager-service/services/mcp_proxy_deployment.go
  • agent-manager-service/services/mcp_proxy_deployment_test.go
  • agent-manager-service/services/mcp_proxy_service.go
  • agent-manager-service/spec/model_create_llm_provider_request.go
  • agent-manager-service/spec/model_llm_provider_response.go
  • agent-manager-service/spec/model_llm_proxy_config.go
  • agent-manager-service/spec/model_mcp_proxy_endpoint.go
  • agent-manager-service/spec/model_resilience.go
  • agent-manager-service/spec/model_update_llm_provider_request.go
  • agent-manager-service/utils/spec_converter.go
  • console/workspaces/libs/shared-component/src/components/ResilienceTimeoutFields.tsx
  • console/workspaces/libs/shared-component/src/components/index.ts
  • console/workspaces/libs/types/src/api/llm-providers.ts
  • console/workspaces/libs/types/src/api/mcp-proxies.ts
  • console/workspaces/pages/llm-providers/src/form/schema.ts
  • console/workspaces/pages/llm-providers/src/subComponents/AddLLMProviderForm.tsx
  • console/workspaces/pages/llm-providers/src/subComponents/LLMProviderConnectionTab.tsx
  • console/workspaces/pages/llm-providers/src/utils/llmProviderPayload.ts
  • console/workspaces/pages/mcp-proxies/src/subComponents/EndpointFormFields.tsx
  • console/workspaces/pages/mcp-proxies/src/subComponents/MCPProxyConnectionTab.tsx
  • console/workspaces/pages/mcp-proxies/src/subComponents/mcpEndpoints.ts

Comment thread agent-manager-service/services/mcp_proxy_deployment.go Outdated
Comment thread console/workspaces/pages/llm-providers/src/form/schema.ts Outdated
Comment thread console/workspaces/pages/mcp-proxies/src/subComponents/MCPProxyConnectionTab.tsx Outdated
AnoshanJ
AnoshanJ previously approved these changes Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Dependency Validation Results

Dependency name: github.com/golang-jwt/jwt/v5
Version: v5.3.1
Allowed range: >=v5.3.1
Approved: ✅ Yes

Dependency name: github.com/modelcontextprotocol/go-sdk
Version: v1.5.0
Allowed range: >=v1.2.0
Approved: ✅ Yes

Dependency name: golang.org/x/crypto
Version: v0.54.0 (was v0.48.0)
Allowed range: >=v0.31.0
Approved: ✅ Yes

Dependency name: golang.org/x/sync
Version: v0.22.0 (was v0.19.0)
Allowed range: >=v0.16.0
Approved: ✅ Yes

⚠️ Please verify the scope of the dependencies usage is necessary

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
agent-manager-service/services/mcp_proxy_deployment.go (1)

422-430: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve Ref-only upstream configurations.

This code copies only Main.URL and rejects an empty URL. If Main.Ref is the optional upstream-reference field added by this PR, a valid Ref-only configuration fails with "upstream URL is required" and the reference is not serialized.

Copy Main.Ref into upstream.Ref. Reject the configuration only when both URL and Ref are empty. Update the error to mention both fields. This repeats the previous missing-Ref finding, so verify the current contract before merging.

Proposed fix
 	if proxy.Configuration.Upstream.Main != nil {
-		upstream.URL = strings.TrimSpace(proxy.Configuration.Upstream.Main.URL)
+		main := proxy.Configuration.Upstream.Main
+		upstream.URL = strings.TrimSpace(main.URL)
+		upstream.Ref = strings.TrimSpace(main.Ref)
-		upstreamAuth = proxy.Configuration.Upstream.Main.Auth
+		upstreamAuth = main.Auth
 	}
-	if strings.TrimSpace(upstream.URL) == "" {
-		return nil, fmt.Errorf("upstream URL is required")
+	if strings.TrimSpace(upstream.URL) == "" && strings.TrimSpace(upstream.Ref) == "" {
+		return nil, fmt.Errorf("upstream URL or Ref is required")
 	}

Run this verification script:

#!/bin/bash
set -euo pipefail

ast-grep outline agent-manager-service/services/mcp_proxy_deployment.go \
  --items all --type function --match 'buildMCPProxyDeploymentYAML'

rg -n -C 5 \
  'type MCPProxyUpstream|Ref.*json|Ref.*yaml|Main\.Ref|MCPProxyUpstream\{' \
  agent-manager-service --glob '*.go'

rg -n -C 8 \
  'Ref|upstream URL|required|buildMCPProxyDeploymentYAML' \
  agent-manager-service/services/mcp_proxy_deployment_test.go
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-manager-service/services/mcp_proxy_deployment.go` around lines 422 -
430, Update buildMCPProxyDeploymentYAML to copy
proxy.Configuration.Upstream.Main.Ref into upstream.Ref, and reject the
configuration only when both trimmed upstream.URL and upstream.Ref are empty.
Change the validation error to mention both URL and Ref, preserving
serialization for Ref-only upstream configurations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@agent-manager-service/services/mcp_proxy_deployment.go`:
- Around line 422-430: Update buildMCPProxyDeploymentYAML to copy
proxy.Configuration.Upstream.Main.Ref into upstream.Ref, and reject the
configuration only when both trimmed upstream.URL and upstream.Ref are empty.
Change the validation error to mention both URL and Ref, preserving
serialization for Ref-only upstream configurations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 63c0c0c4-b209-4c11-b222-82d6e58019e0

📥 Commits

Reviewing files that changed from the base of the PR and between bb4eaa7 and e2d0530.

📒 Files selected for processing (1)
  • agent-manager-service/services/mcp_proxy_deployment.go

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@console/workspaces/pages/configure-agent/src/ViewLLMProvider.Component.tsx`:
- Around line 70-74: Update DURATION_PATTERN used by validateResilienceDuration
to accept fractional numeric durations such as 1.5s while continuing to support
existing integer values, units, and blank input behavior. Ensure the validator
matches the OpenAPI Resilience schema so valid saved overrides can be
resubmitted.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c0a807a4-a0c2-46ba-b2ab-e3f60867ce6d

📥 Commits

Reviewing files that changed from the base of the PR and between e2d0530 and b8f558d.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (12)
  • agent-manager-service/controllers/agent_configuration_controller.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/agent_configuration_dto.go
  • agent-manager-service/services/agent_configuration_service.go
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/services/llm_proxy_deployment_service.go
  • agent-manager-service/services/llm_proxy_deployment_service_test.go
  • agent-manager-service/services/mcp_proxy_deployment.go
  • agent-manager-service/spec/model_env_provider_configuration.go
  • agent-manager-service/spec/model_provider_config.go
  • console/workspaces/libs/types/src/api/agent-model-configs.ts
  • console/workspaces/pages/configure-agent/src/ViewLLMProvider.Component.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • agent-manager-service/services/mcp_proxy_deployment.go

Comment on lines +70 to +74
const DURATION_PATTERN = /^\d+(ms|s|m|h)$/;

function validateResilienceDuration(value: string): string | null {
if (value.trim() === "" || DURATION_PATTERN.test(value.trim())) return null;
return "Enter a duration like 5s, 500ms, or 1m";

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Accept fractional durations in the console validator.

The OpenAPI Resilience schema accepts values such as 1.5s. DURATION_PATTERN rejects them. A valid saved override then loads into this form but cannot be saved.

Match the console pattern to the API contract.

Proposed fix
-const DURATION_PATTERN = /^\d+(ms|s|m|h)$/;
+const DURATION_PATTERN = /^\d+(\.\d+)?(ms|s|m|h)$/;

Also applies to: 507-518

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@console/workspaces/pages/configure-agent/src/ViewLLMProvider.Component.tsx`
around lines 70 - 74, Update DURATION_PATTERN used by validateResilienceDuration
to accept fractional numeric durations such as 1.5s while continuing to support
existing integer values, units, and blank input behavior. Ensure the validator
matches the OpenAPI Resilience schema so valid saved overrides can be
resubmitted.

@menakaj
menakaj merged commit 7347788 into wso2:main Aug 9, 2026
12 checks passed
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.

LLM Service Providers: provide timeout override option

2 participants