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

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
docker, go

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Python
Stars
7
Forks
5
Avg merge
3h 39m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from orka-agents/agentkit

All issues in orka-agents/agentkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.