Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Python: [Bug]: OllamaEmbeddingClient drops numeric zero keep_alive

Cerrado
#8,927 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@eavanvalkenburg ya está trabajando en esto.

Desde el 1/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
Python
Estrellas
14.2k
Forks
2.5k
Merge medio
2 d 11 h
PR fusionados (30 d)
407

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/agent-framework

Todos los issues de microsoft/agent-framework

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.