docs/versioned_docs/version-0.17.2/agents/quickstart.mdx
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Estimated time: 5 minutes
In this guide you will create your first coding agent!
The agent will use an LLM of your choosing to solve a coding prompt. The agent will have access to tools to write code and validate it.
Follow the LLM endpoint configuration instructions to configure an LLM for use with Dagger.
First, you will create a Dagger module. This module will be the place where you write your agent functions.
You can write your module in Go, Python, Typescript, PHP, or Java. Choose the SDK you are most comfortable with.
<Tabs groupId="language"> <TabItem value="Go"> ```bash dagger init --sdk go --name coding-agent ``` </TabItem> <TabItem value="Python"> ```bash dagger init --sdk python --name coding-agent ``` </TabItem> <TabItem value="Typescript"> ```bash dagger init --sdk typescript --name coding-agent ``` </TabItem> <TabItem value="PHP"> ```bash dagger init --sdk php --name coding-agent ``` </TabItem> <TabItem value="Java"> ```bash dagger init --sdk java --name coding-agent ``` </TabItem> </Tabs>This will generate a bunch of files that make up the Dagger module, including some boilerplate functions as examples.
To see the generated functions, run:
dagger functions
You should see information about the generated container-echo and grep-dir functions.
Before you write the agent's function, this agent has a dependency that needs to be installed. This dependency provides the environment the LLM you use to solve the coding prompt.
Learn more about agent environments.
dagger install github.com/shykes/toy-programmer/toy-workspace
Toy-workspace is a Dagger module that provides a simple environment for the agent. It has a Container as its state and functions to read, write, and build the code.
Edit the agent (main.go) and replace the generated code with this code:
Edit the agent (src/coding_agent/main.py) and replace the generated code with this code:
Edit the agent (src/index.ts) and replace the generated code with this code:
Edit the agent (src/CodingAgent.php) and replace the generated code with this code:
Edit the agent (src/main/java/io/dagger/modules/codingagent/CodingAgent.java) and replace the generated code with this code:
In this code you created a function called go-program that takes in an assignment and returns a Container.
ToyWorkspace is given to the LLM to provide it tools to write and validate code.llm -> toy-workspace -> container. This works because you gave the LLM the ToyWorkspace earlier in the chain.Run dagger to enter the shell.
Check out the help text for your new function:
.help
.help go-program
This should show how to use the go-program function.
Make sure your LLM provider has been properly configured:
llm | model
This should show the model you've configured to use with your provider.
Now run the function:
go-program "write a curl clone"
You'll see the agent receive the prompt, write code, validate it, and return the container. If the LLM fails to write code that passes validation, try adding more helpful guidance to the prompt in your function.
Once it has successfully written code, you can get a terminal in the container:
go-program "write a curl clone" | terminal
Run the program. This will look slightly different depending on how the LLM wrote the code:
> ls
# should see a main.go and a go.mod, maybe other files
> go run main.go https://dagger.io
Congratulations! You've created your first coding agent. You can now use this agent to solve coding prompts using an LLM.
Now that you've grasped the basics of building an agent, look at the Dagger AI Agent examples for more examples and ideas for your next agent.