Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Python: [Bug]: OllamaEmbeddingClient drops numeric zero keep_alive

Chiusa
#8,927 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@eavanvalkenburg ci sta già lavorando.

Dal 1/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

agents python reproduced
Description

OllamaEmbeddingClient.get_embeddings silently drops numeric keep_alive=0 and 0.0 from the request. Ollama accepts numeric zero as an explicit keep-alive duration; the framework's declared option type also accepts it.

The embedding adapter uses if keep_alive := opts.get("keep_alive"), so zero is treated as absent. The real Ollama SDK serializes zero correctly when called directly. String "0", negative durations and positive durations are forwarded by the framework.

Expected: explicitly supplied numeric zero reaches /api/embed, while an omitted setting remains omitted.

Observed: the framework sends only model and input for numeric zero.

Reproduction
import asyncio
import json

import httpx
from ollama import AsyncClient
from agent_framework_ollama import OllamaEmbeddingClient

async def main():
    def respond(request):
        print(json.loads(request.content))
        return httpx.Response(200, json={"model": "test-model", "embeddings": [[0.1, 0.2]]})

    sdk = AsyncClient(host="http://ollama.test", transport=httpx.MockTransport(respond))
    async with sdk._client:
        client = OllamaEmbeddingClient(model="test-model", client=sdk)
        await client.get_embeddings(["hello"], options={"keep_alive": 0})
        await sdk.embed(model="test-model", input=["hello"], keep_alive=0)

asyncio.run(main())

Output before the fix:

{'model': 'test-model', 'input': ['hello']}
{'model': 'test-model', 'input': ['hello'], 'keep_alive': 0.0}
Environment

Current main 7634356a1de0fd5de287544113c34d32afeeba83, Python 3.11.15, Ollama SDK 0.5.3. Reproduction uses the real SDK with a simulated HTTP transport and needs no model/server.

Proposed contribution

I have prepared a focused change to use an explicit is not None guard and add HTTP-boundary regression coverage for zero and existing duration/omission behavior. I would like to contribute this fix. It adds no API or dependency.

Lingua principale
Python
Stelle
14k
Fork
2.5k
Merge medio
2g 2h
PR unite (30g)
389

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/agent-framework

Tutte le issue di microsoft/agent-framework

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.