Skip to content

fix(adk): handle Ollama options written as strings - #3279

Open
piyush182004 wants to merge 2 commits into
kagent-dev:mainfrom
piyush182004:fix/ollama-option-coercion
Open

piyush182004 wants to merge 2 commits into
kagent-dev:mainfrom
piyush182004:fix/ollama-option-coercion

Conversation

@piyush182004

Copy link
Copy Markdown

Options come from the CRD as strings, but the coercion was too strict. num_ctx: "2048.0" crashed the agent with a ValueError, and booleans only worked when spelled exactly "true" — "1" or "yes" silently turned off.

Now int options accept "2048.0", bools accept the usual 1/0, yes/no, on/off, and a value we can't parse is passed through with a warning instead of crashing.

ISSUE FIX #3245

Options come from the CRD as strings, but the coercion was too strict.
num_ctx: "2048.0" crashed the agent with a ValueError, and booleans only
worked when spelled exactly "true" — "1" or "yes" silently turned off.

Now int options accept "2048.0", bools accept the usual 1/0, yes/no,
on/off, and a value we can't parse is passed through with a warning
instead of crashing.

Signed-off-by: Piyush Mondal <piyushmondal182004@gmail.com>
@piyush182004
piyush182004 requested a review from a team as a code owner October 19, 2026 13:58
@github-actions github-actions Bot added the bug Something isn't working label Oct 19, 2026
Comment thread python/packages/kagent-adk/src/kagent/adk/types.py Outdated
Comment thread python/packages/kagent-adk/src/kagent/adk/types.py Outdated
Address review: int(float(value)) truncated "2048.5" to 2048 and raised
an uncaught OverflowError on "inf"/"1e400". Only accept a plain integer
or an exactly-integral finite float; forward anything else with a warning.

Signed-off-by: Piyush Mondal <piyushmondal182004@gmail.com>
@piyush182004

Copy link
Copy Markdown
Author

Thank you @moezdil for the review, replaced int(float(value)) with a helper that only accepts a plain integer or an exactly integral finite float — "2048.5" is now forwarded instead of truncated, and "inf"/"nan"/"1e400" no longer raise OverflowError. Added tests for all of these. Pushed the fixes,please check once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Ollama ModelConfig options: integer coercion crashes on decimal strings, and boolean options only accept exact "true"

2 participants