Skip to content

feat: configurable keep alive duration in network config - #5328

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-17-feat_configurable_keep_alive_duration_in_network_config
Jul 17, 2026
Merged

feat: configurable keep alive duration in network config#5328
Pratham-Mishra04 merged 1 commit into
devfrom
07-17-feat_configurable_keep_alive_duration_in_network_config

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

The idle connection keep-alive timeout for all provider HTTP clients was previously hardcoded (30s for most providers, 60s for Runware and Runway). This PR replaces those hardcoded values with a configurable keep_alive_timeout_in_seconds field on NetworkConfig, defaulting to 30 seconds. This allows operators to tune the idle connection lifetime to stay below the upstream server's own keep-alive timeout, preventing Bifrost from attempting to reuse connections that the server has already closed.

Changes

  • Added KeepAliveTimeoutInSeconds to NetworkConfig with a default of 30 seconds, validation in CheckAndSetDefaults, and full JSON marshal/unmarshal support.
  • Replaced all hardcoded MaxIdleConnDuration / IdleConnTimeout values across every provider (including the previously special-cased 60s values for Runware and Runway) with time.Second * time.Duration(config.NetworkConfig.KeepAliveTimeoutInSeconds).
  • Added keep_alive_timeout_in_seconds to the JSON config schema with minimum: 1 and maximum: 3600.
  • Added a Keep-Alive Timeout input field to the provider network configuration form in the UI, with validation (1–3600), human-readable duration display, and a default of 30.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Set keep_alive_timeout_in_seconds in a provider's network_config and confirm the value is respected at runtime. Omitting the field should fall back to the 30-second default. Setting it to 0 or a negative value should also fall back to the default via CheckAndSetDefaults.

Breaking changes

  • Yes
  • No

The default value (30s) matches the previous hardcoded value for all providers except Runware and Runway, which previously used 60s. Those two providers will now default to 30s unless keep_alive_timeout_in_seconds: 60 is explicitly set in their config.

Related issues

Security considerations

None. This change only affects connection pool lifecycle timing and introduces no new secrets, auth paths, or PII handling.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

TejasGhatte commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ad4d309-e242-4184-a146-05421d122f20

📥 Commits

Reviewing files that changed from the base of the PR and between 343680e and e61fa61.

📒 Files selected for processing (35)
  • core/providers/anthropic/anthropic.go
  • core/providers/azure/azure.go
  • core/providers/bedrock/bedrock.go
  • core/providers/bedrockmantle/bedrockmantle.go
  • core/providers/cerebras/cerebras.go
  • core/providers/cohere/cohere.go
  • core/providers/deepseek/deepseek.go
  • core/providers/elevenlabs/elevenlabs.go
  • core/providers/fireworks/fireworks.go
  • core/providers/gemini/gemini.go
  • core/providers/groq/groq.go
  • core/providers/huggingface/huggingface.go
  • core/providers/mistral/mistral.go
  • core/providers/nebius/nebius.go
  • core/providers/ollama/ollama.go
  • core/providers/openai/openai.go
  • core/providers/opencode/opencode.go
  • core/providers/openrouter/openrouter.go
  • core/providers/parasail/parasail.go
  • core/providers/perplexity/perplexity.go
  • core/providers/replicate/replicate.go
  • core/providers/runware/runware.go
  • core/providers/runway/runway.go
  • core/providers/sarvam/sarvam.go
  • core/providers/sgl/sgl.go
  • core/providers/vertex/vertex.go
  • core/providers/vllm/vllm.go
  • core/providers/xai/xai.go
  • core/schemas/provider.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/networkFormFragment.tsx
  • ui/lib/constants/config.ts
  • ui/lib/schemas/providerForm.ts
  • ui/lib/types/config.ts
  • ui/lib/types/schemas.ts
📝 Walkthrough

Walkthrough

Adds a configurable pooled-connection keep-alive timeout to backend and UI network configuration, persists and validates it, and applies it across provider HTTP clients instead of fixed idle durations.

Changes

Keep-alive configuration

Layer / File(s) Summary
Backend keep-alive contract
core/schemas/provider.go, transports/config.schema.json
Adds keep_alive_timeout_in_seconds, including defaults, JSON serialization, validation, and schema constraints of 1–3600 seconds.
Provider form keep-alive setting
ui/lib/types/config.ts, ui/lib/types/schemas.ts, ui/lib/schemas/providerForm.ts, ui/lib/constants/config.ts, ui/app/workspace/providers/fragments/networkFormFragment.tsx
Adds the setting to UI types, defaults, validation, form initialization, submission, reset handling, and the timeouts section.
Provider client idle durations
core/providers/*/*.go
Configures provider HTTP client idle connection durations from NetworkConfig.KeepAliveTimeoutInSeconds, including Bedrock transport settings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: akshaydeo, danpiths, pratham-mishra04

Sequence Diagram(s)

sequenceDiagram
  participant NetworkFormFragment
  participant ProviderConfig
  participant ProviderClient
  NetworkFormFragment->>ProviderConfig: submit keep_alive_timeout_in_seconds
  ProviderConfig->>ProviderConfig: marshal and apply defaults
  ProviderConfig->>ProviderClient: initialize idle duration from KeepAliveTimeoutInSeconds
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 96.55% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: configurable keep-alive duration in network config.
Description check ✅ Passed The description closely follows the template and covers summary, changes, type, areas, testing, breaking changes, security, and checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-17-feat_configurable_keep_alive_duration_in_network_config

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

@TejasGhatte
TejasGhatte marked this pull request as ready for review July 17, 2026 08:50
@CLAassistant

CLAassistant commented Jul 17, 2026

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.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • The form now preserves valid timeout values through validation and submission.
  • No new blocking issue remains in the updated code.

Important Files Changed

Filename Overview
core/schemas/provider.go Adds the keep-alive setting, default handling, and JSON serialization.
ui/app/workspace/providers/fragments/networkFormFragment.tsx Adds the keep-alive input and includes its value in form initialization, reset, and submission.
ui/lib/types/schemas.ts Adds integer and range validation for the keep-alive field.
transports/config.schema.json Adds the keep-alive field to both network configuration schema definitions.

Reviews (4): Last reviewed commit: "feat: configurable keep alive duration i..." | Re-trigger Greptile

Comment thread ui/app/workspace/providers/fragments/networkFormFragment.tsx
Comment thread core/providers/runway/runway.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 `@core/schemas/provider.go`:
- Around line 585-587: Update the KeepAliveTimeoutInSeconds validation in the
ProviderConfig normalization path to replace values outside the documented
1–3600-second range, including values above 3600, with the existing default.
Reuse the configuration schema’s shared maximum constant if available rather
than hardcoding a duplicate limit, while preserving valid values unchanged.
🪄 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 Plus

Run ID: ea923256-cfbe-4526-b386-33d35e5a579d

📥 Commits

Reviewing files that changed from the base of the PR and between 36391e1 and 818ffb1.

📒 Files selected for processing (34)
  • core/providers/anthropic/anthropic.go
  • core/providers/azure/azure.go
  • core/providers/bedrock/bedrock.go
  • core/providers/bedrockmantle/bedrockmantle.go
  • core/providers/cerebras/cerebras.go
  • core/providers/cohere/cohere.go
  • core/providers/deepseek/deepseek.go
  • core/providers/elevenlabs/elevenlabs.go
  • core/providers/fireworks/fireworks.go
  • core/providers/gemini/gemini.go
  • core/providers/groq/groq.go
  • core/providers/huggingface/huggingface.go
  • core/providers/mistral/mistral.go
  • core/providers/nebius/nebius.go
  • core/providers/ollama/ollama.go
  • core/providers/openai/openai.go
  • core/providers/opencode/opencode.go
  • core/providers/openrouter/openrouter.go
  • core/providers/parasail/parasail.go
  • core/providers/perplexity/perplexity.go
  • core/providers/replicate/replicate.go
  • core/providers/runware/runware.go
  • core/providers/runway/runway.go
  • core/providers/sarvam/sarvam.go
  • core/providers/sgl/sgl.go
  • core/providers/vertex/vertex.go
  • core/providers/vllm/vllm.go
  • core/providers/xai/xai.go
  • core/schemas/provider.go
  • transports/config.schema.json
  • ui/app/workspace/providers/fragments/networkFormFragment.tsx
  • ui/lib/constants/config.ts
  • ui/lib/schemas/providerForm.ts
  • ui/lib/types/config.ts

Comment thread core/schemas/provider.go
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 17, 2026
@TejasGhatte
TejasGhatte force-pushed the 07-17-feat_configurable_keep_alive_duration_in_network_config branch from 818ffb1 to 343680e Compare July 17, 2026 09:16

Pratham-Mishra04 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Merge activity

  • Jul 17, 11:14 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 17, 11:25 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 17, 11:27 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 17, 11:27 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 07-16-fix_reasoning_item_streaming_in_mux to graphite-base/5328 July 17, 2026 11:18
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5328 to dev July 17, 2026 11:24
@Pratham-Mishra04
Pratham-Mishra04 dismissed coderabbitai[bot]’s stale review July 17, 2026 11:24

The base branch was changed.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-17-feat_configurable_keep_alive_duration_in_network_config branch from 343680e to 4fbaea3 Compare July 17, 2026 11:24
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-17-feat_configurable_keep_alive_duration_in_network_config branch from 4fbaea3 to e61fa61 Compare July 17, 2026 11:26
@Pratham-Mishra04
Pratham-Mishra04 merged commit 4ff7980 into dev Jul 17, 2026
13 of 15 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-17-feat_configurable_keep_alive_duration_in_network_config branch July 17, 2026 11:27
akshaydeo pushed a commit that referenced this pull request Jul 17, 2026
## Summary

The idle connection keep-alive timeout for all provider HTTP clients was previously hardcoded (30s for most providers, 60s for Runware and Runway). This PR replaces those hardcoded values with a configurable `keep_alive_timeout_in_seconds` field on `NetworkConfig`, defaulting to 30 seconds. This allows operators to tune the idle connection lifetime to stay below the upstream server's own keep-alive timeout, preventing Bifrost from attempting to reuse connections that the server has already closed.

## Changes

- Added `KeepAliveTimeoutInSeconds` to `NetworkConfig` with a default of 30 seconds, validation in `CheckAndSetDefaults`, and full JSON marshal/unmarshal support.
- Replaced all hardcoded `MaxIdleConnDuration` / `IdleConnTimeout` values across every provider (including the previously special-cased 60s values for Runware and Runway) with `time.Second * time.Duration(config.NetworkConfig.KeepAliveTimeoutInSeconds)`.
- Added `keep_alive_timeout_in_seconds` to the JSON config schema with `minimum: 1` and `maximum: 3600`.
- Added a `Keep-Alive Timeout` input field to the provider network configuration form in the UI, with validation (1–3600), human-readable duration display, and a default of 30.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `keep_alive_timeout_in_seconds` in a provider's `network_config` and confirm the value is respected at runtime. Omitting the field should fall back to the 30-second default. Setting it to `0` or a negative value should also fall back to the default via `CheckAndSetDefaults`.

## Breaking changes

- [ ] Yes
- [x] No

The default value (30s) matches the previous hardcoded value for all providers except Runware and Runway, which previously used 60s. Those two providers will now default to 30s unless `keep_alive_timeout_in_seconds: 60` is explicitly set in their config.

## Related issues

## Security considerations

None. This change only affects connection pool lifecycle timing and introduces no new secrets, auth paths, or PII handling.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Jul 18, 2026
## Summary

The idle connection keep-alive timeout for all provider HTTP clients was previously hardcoded (30s for most providers, 60s for Runware and Runway). This PR replaces those hardcoded values with a configurable `keep_alive_timeout_in_seconds` field on `NetworkConfig`, defaulting to 30 seconds. This allows operators to tune the idle connection lifetime to stay below the upstream server's own keep-alive timeout, preventing Bifrost from attempting to reuse connections that the server has already closed.

## Changes

- Added `KeepAliveTimeoutInSeconds` to `NetworkConfig` with a default of 30 seconds, validation in `CheckAndSetDefaults`, and full JSON marshal/unmarshal support.
- Replaced all hardcoded `MaxIdleConnDuration` / `IdleConnTimeout` values across every provider (including the previously special-cased 60s values for Runware and Runway) with `time.Second * time.Duration(config.NetworkConfig.KeepAliveTimeoutInSeconds)`.
- Added `keep_alive_timeout_in_seconds` to the JSON config schema with `minimum: 1` and `maximum: 3600`.
- Added a `Keep-Alive Timeout` input field to the provider network configuration form in the UI, with validation (1–3600), human-readable duration display, and a default of 30.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `keep_alive_timeout_in_seconds` in a provider's `network_config` and confirm the value is respected at runtime. Omitting the field should fall back to the 30-second default. Setting it to `0` or a negative value should also fall back to the default via `CheckAndSetDefaults`.

## Breaking changes

- [ ] Yes
- [x] No

The default value (30s) matches the previous hardcoded value for all providers except Runware and Runway, which previously used 60s. Those two providers will now default to 30s unless `keep_alive_timeout_in_seconds: 60` is explicitly set in their config.

## Related issues

## Security considerations

None. This change only affects connection pool lifecycle timing and introduces no new secrets, auth paths, or PII handling.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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