[BUG] Ollama ModelConfig options: integer coercion crashes on decimal strings, and boolean options only accept exact "true"
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
python/packages/kagent-adk/src/kagent/adk/types.pyから始め、Ollama SDKのOptions型を使って文字列値を処理する_convert_ollama_optionsを確認してください。この変換を対象とする既存のテストがあるか確認し、整数を表す小数文字列、一般的な真偽値の表記、変換できない値を対象とするテストを追加してください。これらの入力が説明どおりに処理され、エージェントの作成が失敗しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
📋 Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
- I am using the latest version of the software
- I have tried to clear cache/cookies or used incognito mode (if ui-related)
- I can consistently reproduce this issue
🎯 Affected Service(s)
App Service
🚦 Impact/Severity
Blocker
🐛 Bug Description
_convert_ollama_options in python/packages/kagent-adk/src/kagent/adk/types.py converts the Ollama option values from the ModelConfig CRD (which arrive as strings) into the types the Ollama SDK expects. It has two bugs.
1. Integer options crash the agent build on a decimal string. int(value) is called directly, so an integer-typed option such as num_ctx: "2048.0" raises ValueError: invalid literal for int() with base 10: '2048.0'. This happens while the model is being constructed, so the entire agent fails to start rather than degrading gracefully.
2. Boolean options are only recognised as the exact string "true". The code uses value.lower() == "true", so common spellings such as "1", "yes" and "on" silently evaluate to False. Several Ollama options are booleans (numa, low_vram, f16_kv, use_mmap, use_mlock, logits_all, vocab_only, embedding_only, penalize_newline), so a user who enables one with low_vram: "1" gets it silently turned off with no warning.
🔄 Steps To Reproduce
- Configure an agent with an Ollama ModelConfig whose
optionscontain an integer value written with a decimal point, e.g.num_ctx: "2048.0"(values arrive from the CRD as strings). - Start the agent. The Python runtime calls
_convert_ollama_optionswhile building the model. - Observe the agent fails to build with
ValueError: invalid literal for int() with base 10: '2048.0'.
Minimal reproduction of the coercion function in isolation:
from kagent.adk.types import _convert_ollama_options
_convert_ollama_options({"num_ctx": "2048.0"}) # raises ValueError
_convert_ollama_options({"low_vram": "1"}) # -> {"low_vram": False} (expected True)
_convert_ollama_options({"low_vram": "yes"}) # -> {"low_vram": False} (expected True)
🤔 Expected Behavior
- Integer options accept integral decimal strings such as
"2048.0". - Boolean options accept the usual truthy/falsy spellings (
1/0,true/false,yes/no,on/off), case-insensitively. - A value that genuinely cannot be converted is forwarded to the Ollama SDK (which reports it) instead of raising and failing agent construction.
📱 Actual Behavior
num_ctx: "2048.0"raisesValueError: invalid literal for int() with base 10: '2048.0'during model construction, so the whole agent fails to start.low_vram: "1"andlow_vram: "yes"silently becomeFalse, so the option is quietly ignored with no warning.
Confirmed end to end against a running Ollama: with options: {num_ctx: "2048.0", low_vram: "1"} the current coercion raises before Ollama is ever called; with tolerant coercion the options become {num_ctx: 2048, low_vram: True} and the model responds normally.
💻 Environment
- Application version: latest
main - Affected component: Python ADK runtime (
kagent-adk) - File:
python/packages/kagent-adk/src/kagent/adk/types.py(_convert_ollama_options) - OS: not OS-specific (pure Python coercion logic)
🔧 CLI Bug Report
No response
🔍 Additional Context
The affected function uses the Ollama SDK's Options model for type introspection, so the set of int/float/bool fields is taken from the SDK. The fix is a tolerant coercion: accept integral decimal strings for int fields, parse the common boolean spellings, and fall back to forwarding the raw value (with a warning) when a value cannot be converted, rather than raising.
No known workaround other than writing integer options without a decimal point and booleans as exactly "true".
📋 Logs
No response
📷 Screenshots
No response
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
- 主要言語
- Go
- スター
- 4.1k
- フォーク
- 871
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 170
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
kagent-dev/kagent のほかの issue
-
[BUG] OpenAI and Ollama adapters send an empty tool message when a tool returns a dict対応中かも @helloxjade が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
kagent-dev/kagent#3462 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
kagent-dev/kagent#3428 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]対応中かも @helloxjade が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
kagent-dev/kagent#3385 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Go Ollama adapter does not send tool_name on tool result messages対応中かも @mandipadk が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
kagent-dev/kagent#3371 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kagent-dev/kagent#3247 ·
メンテナーはふだん 1 日以内に返信
kagent-dev/kagent の issue をすべて見る
似ている issue
-
Fix mode unpins a reusable workflow call when the same repository is also used as a step actionオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
github/gh-actions-lock#261 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
labmonkeys-space/nl6#974 ·
メンテナーはふだん 1 日以内に返信
-
model:sonnet phase-2-optimize runtime:claude security size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
FootprintAI/Containarium#3471 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] serviceenvupdater filter does not update KUBERNETES_SERVICE_HOST/PORT in init containers対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openyurtio/openyurt#2845 ·
メンテナーはふだん 7 日以内に返信
-
fuzz.yml skips three fuzz targets, and the Action's user input describes only ~/.claude対応中かも @predictor2718 が今日担当しました。 オープンgithub_actions P3 tests
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信