These docs are new.
Expect rough edges. If something is missing or hard to follow, tell us on Discord or by mail at hallo@knecht.works.
Usage

AI Agent

How the agent works inside your project and how to steer it.

The AI step starts opencode inside the project's environment with your provider key. It is an agent, not a chat: it reads the code, changes files, runs commands, and checks its own work until the task in the prompt is done. This page covers where it runs, how to steer it, and what it hands back to the workflow.

Where It Runs

The agent runs inside the web container of the booted project, as a non-root user, on the run's checkout. Composer, npm, and git are there, so it behaves like a developer on the real project. What it cannot reach:

  • Docker and the host: The Docker socket and the DDEV CLI stay on the Knecht side. The agent only ever sees the inside of its container.
  • Other runs: Each environment sits on its own network, parallel runs cannot reach each other.
  • Secrets: The provider key is handed to the process as an environment variable and never written into the checkout. Git pushes go through a short-lived token scoped to the session's one repository.

A small set of Knecht commands is available to the agent inside the container: git with credentials for the project's repository, a command to push the branch and open a pull request, and, when the session belongs to a GitHub issue or pull request or to an issue of an issue tracker, commands to read the thread, post a reply, add or remove existing labels, and, in an issue tracker, move it to another status. What each of them does is on the page of the integration, in the section about the agent, for example on GitHub.

Instructions

Three layers of instructions apply, in this order:

  1. Built-in rules: Knecht ships its own rules for working style, git usage, memory, and how to reply on a thread. They are the same on every instance.
  2. Instance instructions: Settings > Agent has a free text field that applies to every project, for example "Always answer in German" or "Never touch anything under legacy/". Every member can edit it.
  3. Project instructions: The project settings have the same field for rules that apply to this project only, for example where the styles live or which design tokens to use.

On conflict, the step's prompt or the follow-up request wins, then project, then instance instructions. All of them apply even when the request does not mention them. A repository's own AGENTS.md is read by opencode as usual.

Memory

The agent keeps notes per project, so it does not rediscover the same facts on every run: how the project builds, where the styles live, corrections from earlier follow-ups. The notes live on the host outside every environment and are copied into the checkout before each agent call and back afterwards.

The structure is an index file, MEMORY.md, that is part of the agent's instructions on every call, plus topic files the agent reads on demand. The agent writes and curates the notes itself, guided by the built-in rules. The index is capped at 2 KB and the whole store at 64 KB. An oversized write is discarded and the previous state kept.

There is no view of the notes in the dashboard yet.

Output Fields

By default, an AI step returns the agent's final text under {{ steps.<id>.text }}. For later steps that need specific values, the step's "Output format" field declares them, one per line:

prTitle: string
labels: string[]
needsReview: boolean

The allowed types are string, number, boolean, and their array forms. The agent writes the result as a file, Knecht validates it against the declaration and asks the agent to fix it if it does not match. Each field is then available as {{ steps.<id>.json.<field> }}, for example as the title of the pull request step.

Models

The default model and an optional subtask model are set in the global AI settings, or per project, see AI Connection per Project below. The subtask model is used when the agent delegates smaller pieces of work, for example exploring the repository. Each AI step has a model field that overrides the default, so one workflow can mix a small model for triage and a large one for the fix, all behind the same key. Besides the models of the provider, the field offers two entries that follow the settings:

  • "Default model": the default model of the project's connection.
  • "Default subtask model": the subtask model of the project's connection, or the default model when none is set.

Switching the provider clears the key and both stored models, because neither carries over between providers. A dialog asks before the switch, then you save the new provider's key and a default model is preselected. Only owners change provider, key, and models.

AI Connection per Project

A project uses the global AI settings until you change them in the project settings under "Advanced" > "AI connection". Every field you leave untouched keeps the global value. This way a project can, for example, run on the client's own key.

Two special cases:

  • A model the project's provider lacks: Workflows are shared by all projects, so an AI step can ask for a model the project's own provider does not have. That step runs with the global AI settings.
  • A new global provider: Projects with their own key keep the previous provider. All other projects switch to the new one.
Keep the global AI settings configured even when every project has its own connection. Planned AI features that belong to no project, for example help with creating workflows, will run on them.

MCP Servers

The agent can also use the tools of remote MCP servers, for example Sentry or Notion. How to set them up and sign in is on MCP Servers.

Follow-Ups and Mentions

The conversation does not end with the run. Every session has one agent conversation that every AI step and follow-up continues, so later work sees what earlier work found. A step with its own model switches the model within it. A step can instead turn on "Fresh context" to start without that history, for example a triage step that should not be swayed by an earlier attempt; its final message still becomes part of the session's conversation for the next turn. Two ways to continue:

  • The follow-up chat on the run page sends a new prompt into the session's environment.
  • A mention in a comment does the same from GitHub or an issue tracker, see Mentions below.

Follow-ups in one session run one after the other. A stopped environment is restarted for the follow-up, an archived one is restored first.

For a walkthrough of setting this up end to end, see Exploring Knecht Cloud: Talking to an AI Agent in GitHub Issues.

Mentions

A mention is a comment that addresses Knecht. Knecht runs the text of the comment as a follow-up and posts the answer as a comment in the same thread.

Set it up once per project:

  1. Open the project settings and go to the Mentions panel.
  2. "Start with a preview" (default on): the first mention boots the app so Knecht can check its work. Off is faster, code only.
  3. Optional "Setup workflow": runs once before the first mention, e.g. to seed test data.

Mention Knecht:

WhereWrite
GitHub issue or pull request@knecht-works fix the broken footer link
Issue trackerMention the account Knecht is connected with, the way you mention a colleague, followed by the instruction. @knecht typed as plain text works as well.

The issue has to belong to a project in Knecht: its repository on GitHub, or the project linked to it in an issue tracker.

What happens:

  1. Knecht looks up the session of the issue. If there is none, or its environment is down, Knecht boots a preview or a code-only checkout first, then runs the setup workflow if one is chosen.
  2. The comment runs as a follow-up in that environment, with the agent conversation of the session.
  3. The answer arrives as a comment. In an issue tracker it lands in the mention's thread and tags whoever asked. If a pull request was opened, its link is part of it.

If nothing happens:

Knecht answersReason
Not at allThe issue belongs to no project, or the comment comes from an account that may not mention Knecht, on GitHub one no member has signed in with.

Who may mention Knecht depends on the tool: on GitHub only members' accounts they signed in with, see Your Profile, in an issue tracker everyone who can comment on the issue. Comments by Knecht itself are always ignored. The Mentions section on the page of each integration has the details.

Was this page helpful?