Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Python: [Bug]: OllamaEmbeddingClient drops numeric zero keep_alive

Đã đóng
#8,927 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@eavanvalkenburg đang làm issue này rồi.

Từ ngày 1/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
Python
Star
14.2k
Fork
2.5k
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
384

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/agent-framework

Tất cả issue của microsoft/agent-framework

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.