feat(runtime): let the Agentkitfile choose Chat Completions or Responses

Aperta
#68 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, python, yaml

Direzione di ricerca

Start after #36 merges, then trace the model settings through pkg/agentkit/config/specs.go, pkg/agentkit/effective, and pkg/agentkit/abi to see how agent.yaml is built. Read the configuration and adapter code in runtimes/common/agentkit_serve_common/config.py and adapter_support.py, then check the docs named in the issue. Done means the optional API choice is validated, baked into the YAML without changing existing bytes when omitted, and covered by the specified tests.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/build area/orka area/runtime enhancement

Start after #36 merges. #36 adds the AGENTKIT_MODEL_API environment variable that this issue builds on.

Problem

An AgentKit agent talks to its model through one of two OpenAI-style APIs:

  • Chat Completions (POST /v1/chat/completions) is the older API and AgentKit's default.
  • Responses (POST /v1/responses) is the newer API. Some new reasoning models only allow tool calls through Responses. #32 shows a model where every tool call over Chat Completions fails.

#36 lets you pick the API with an environment variable: AGENTKIT_MODEL_API=chat_completions, responses, or auto. That works with docker run -e ..., but not when Orka runs the agent.

Under Orka, a program called the supervisor starts agentkit-serve --protocol acp as a child process. It gives that process only the environment variables it chooses itself (see BuildChildEnvironment in Orka's internal/acp/runtime_env.go). Variables set in the image or on the Pod never reach AgentKit. So under Orka, AgentKit always uses Chat Completions, and agents on Responses-only models can't use tools.

What

Add an optional model.api field to the Agentkitfile and to the baked /agent/agent.yaml:

model:
  provider: openai-compatible
  baseURL: https://api.openai.com/v1
  name: gpt-6-luna
  apiKeyEnv: OPENAI_API_KEY
  api: responses # chat_completions (default), responses, or auto

It accepts the same three values as AGENTKIT_MODEL_API. When the field is left out, nothing changes.

Out of scope:

  • New model providers or API types.
  • Changing how auto decides which API to use.
  • The Orka side. Orka's model proxy must also let AgentKit send Responses requests. That is tracked in orka-agents/orka#879.

Why

agent.yaml is already the file Orka trusts. When Orka runs AgentKit, it passes a SHA-256 digest of the exact agent.yaml bytes, and AgentKit refuses to start if the file doesn't match (runtimes/common/agentkit_serve_common/acp.py, around lines 353 to 374). Putting the choice in agent.yaml means:

  • It works under Orka with no new Orka setting.
  • It is locked in automatically. Changing the API means building a new image with a new digest, which Orka already checks.
  • The choice lives with the rest of the agent's settings, in one file.

How

  1. Agentkitfile. Add an API field (yaml:"api,omitempty") to the model settings in pkg/agentkit/config/specs.go, next to Provider (around line 24). Accept only chat_completions, responses and auto. Any other value fails the build with a message that lists the allowed values.
  2. Baked agent.yaml. Carry the field through pkg/agentkit/effective and write it in pkg/agentkit/abi. Leave it out when it is empty, so agent.yaml for existing Agentkitfiles stays byte-for-byte the same and their digests don't change.
  3. Python reader. Read model.api in runtimes/common/agentkit_serve_common/config.py and check it against the same three values.
  4. Choosing the API. In runtimes/common/agentkit_serve_common/adapter_support.py, where #36 reads AGENTKIT_MODEL_API (around line 61 on the #36 branch), use this order: the environment variable if it is set, then model.api, then chat_completions. Checking the environment variable first keeps existing docker run -e AGENTKIT_MODEL_API=... setups working. Under Orka the variable is never set, so agent.yaml decides.
  5. Docs. Describe the field in docs/agentkitfile.md and docs/agent-abi.md. In docs/orka.md, note that under Orka this field is the only way to choose the API.

Done when

  • An Agentkitfile with api: responses builds, and the image's /agent/agent.yaml contains api: responses.
  • An Agentkitfile without api produces exactly the same agent.yaml bytes as before.
  • An invalid value fails the build and the message lists the allowed values.
  • A Python test shows each adapter uses Responses when agent.yaml says responses and the environment variable is not set, and that the environment variable wins when both are set.
  • uv run --directory runtimes/common --extra dev pytest -q, go test ./... and make lint pass.
Lingua principale
Python
Stelle
7
Fork
5
Merge medio
3h 39m
PR unite (30g)
1

Preparare l'ambiente

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 orka-agents/agentkit

Tutte le issue di orka-agents/agentkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.