Skip to content

fix(ollama): bound pending native tool calls - #385

Closed
luvs01 wants to merge 1 commit into
devfrom
codex/fix-memory-exhaustion-vulnerability-in-ollama-native
Closed

luvs01 wants to merge 1 commit into
devfrom
codex/fix-memory-exhaustion-vulnerability-in-ollama-native

Conversation

@luvs01

@luvs01 luvs01 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a remotely-controlled Ollama-native upstream from exhausting the proxy process by unboundedly retaining provider-controlled tool names and an unlimited number of pending tool calls.
  • Ensure retained provider data (tool names and per-call bookkeeping) is accounted to the existing translator budget so aggregate in-memory retention is limited.

Description

  • Add hard limits and accounting to the native Ollama parser: introduce NATIVE_TOOL_NAME_MAX_BYTES = 1024, NATIVE_MAX_PENDING_TOOL_CALLS = 128, and a small NATIVE_TOOL_CALL_BOOKKEEPING_BYTES overhead, and enforce them during nativeMessageEvents. (file: src/adapters/ollama-native.ts)
  • Charge retained tool-name bytes plus bookkeeping to the translator budget before storing a new pending NativeStreamToolCall, and fail admission when the budget or per-call/pending-count bounds are exceeded. (file: src/adapters/ollama-native.ts)
  • Add focused regression tests that exercise oversized tool names, excessive pending-call counts, and aggregate retained-name budget enforcement. (file: tests/ollama-native-parser.test.ts)

Testing

  • Ran the focused adapter tests with bun test tests/ollama-native-parser.test.ts and the modified suite passed (29 tests, 0 failures).
  • Ran type checking with bun run typecheck and it succeeded.
  • Started the full test suite bun run test for broader confidence; the run surfaced unrelated pre-existing failures in Lab automation / API auth and a long-running chat-completions timeout, so only the focused Ollama-native tests and typecheck are relied on for this change.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: a8f20d40-8493-4172-98af-206cd0d54291


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T01:00:57.842256Z 8adc6f4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 31, 2026
@github-actions github-actions Bot changed the title fix(ollama): bound pending native tool calls [WRONG BRANCH] fix(ollama): bound pending native tool calls Aug 31, 2026
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

✅ READY

  • all PR quality gates passed.

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft August 31, 2026 01:16
@luvs01 luvs01 changed the title [WRONG BRANCH] fix(ollama): bound pending native tool calls fix(ollama): bound pending native tool calls Sep 3, 2026
@luvs01
luvs01 changed the base branch from main to dev September 3, 2026 06:22
@github-actions
github-actions Bot marked this pull request as ready for review September 3, 2026 06:32
@luvs01

luvs01 commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

Closing: submitted upstream as lidge-jun#5781, rebased onto current dev and verified — bun test tests/providers/ollama/ollama-native-parser.test.ts 29 pass. Nothing left to merge here.

@luvs01 luvs01 closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant