feat(build): add a debug target that outputs the rendered agent.yaml

Aperta
#62 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
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
docker, go

Direzione di ricerca

A linked pull request (#67) is already open, so check its status before starting. The issue points to pkg/build/router.go, pkg/build/build.go, pkg/agentkit/abi/render.go, and pkg/build/build_test.go; begin by reading the existing routing and handleAgent flow. Done means the debug target writes agent.yaml matching the image output without downloading the runtime image, works across runtimes and with context instructions, and is documented.

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

Descrizione

area/build enhancement help wanted

Problem

AgentKit turns your Agentkitfile into a file at /agent/agent.yaml inside the image. Along the way it:

  • reads your instructions file;
  • fills in defaults such as the port and runtime;
  • copies over tools, env names and context providers.

When an agent doesn't behave as expected, the first question is often "what did my file turn into?" Today the only way to find out is to:

  1. build the full image, which downloads the runtime image (hundreds of MB);
  2. read the file out of that image;
  3. or read the Go code.

dalec solves the same problem with debug build targets. debug/resolve outputs the final spec without building anything else (see dalec's frontend/debug/).

What

Add a build target that writes only the rendered file:

docker buildx build -f agentkitfile.yaml . \
  --target debug/agent-yaml \
  --output type=local,dest=./out
# writes ./out/agent.yaml
  • Same file. The output must match /agent/agent.yaml in the image byte for byte.
  • Fast. It doesn't download the runtime image.
  • Same build args. It accepts the same build args as an image build, such as --build-arg runtime=....
  • Listed. It shows up in docker buildx build --call targets (#58).
Out of scope
  • Other debug outputs, such as the image settings or the agent manifest from #55. They can be added the same way later, for example debug/image-config.

Why

  • Quick answers when debugging: see exactly what the runtime will read.
  • No need to build, download, or open the image.
  • It's also useful for reviewing changes: compare the rendered output before and after an edit.

How

Where things are
File What it does
pkg/build/router.go The routes and contextRouteHandlers maps. registerRuntime() adds <runtime>/image. lookupRoute() matches an exact target name first.
pkg/build/build.go handleAgent() resolves the instructions (resolveInstructionSource), builds the build-ready agent (effective.FromConfig) and then builds the image.
pkg/agentkit/abi/render.go abi.Render(agent) returns the exact bytes of /agent/agent.yaml.
pkg/build/build_test.go fakeBuildClient, for tests that don't need a real BuildKit.
Steps
  1. Share the setup. Pull the "config → resolved instructions → build-ready agent" part of handleAgent() into a shared function, so the image build and the debug target can't drift apart.
  2. Add a handler for debug/agent-yaml.
    • Use the shared function, then call abi.Render.
    • Put the bytes in an empty filesystem: llb.Scratch().File(llb.Mkfile("agent.yaml", 0o644, data)).
    • Solve it with c.Solve and return the result. Don't add image settings; this output is files, not an image.
  3. Register the route in both routes and contextRouteHandlers. Instruction files are read from the build context, so the handler needs the context reader.
  4. Check the routing.
    • lookupRoute() should find debug/agent-yaml by exact match, and the runtime-mismatch check (targetRuntimeSegment) must not reject it, because debug isn't a runtime name.
    • Add tests for both, for every runtime.
Tests
  • With fakeBuildClient, target debug/agent-yaml:
    • returns one file, agent.yaml, whose bytes equal abi.Render for the same input;
    • doesn't download the runtime image.
  • It works with an instructions file (instructions: {file: ./prompt.md}) read from the build context.
  • Routing works for each runtime, including aliases such as maf.
  • End to end:
    • build an image from test/agentkitfile-tools.yaml;
    • run the debug target on the same file;
    • compare the output with /agent/agent.yaml from the image.

Run:

go test ./...
make lint
Docs
  • docs/agentkitfile.md: add a short "See what your file turns into" section with the command. Note that it needs --output type=local.

Done when

  • The command above writes agent.yaml, identical to the file in the image, without downloading the runtime image.
  • It works for every runtime and with instruction files.
  • It appears in --call targets once #58 lands.
  • It's documented.
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.