graph-based-agents

A graph-based agent is an AI workflow drawn as a state machine: nodes perform actions such as asking a language model or running a tool, while edges pass data between them.

In plain words
What is it for?
Use it to build agents that ask a language model, respond directly, or call tools and send their results back for another decision.
Why use it?
It makes the agent's steps and decision paths easier to see and lets the workflow keep and reuse state between steps.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/jetbrains/koog/graph-based-agents
Clone the repo
git clone --depth 1 https://github.com/JetBrains/koog
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,137 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin 89% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.07137
Opus 5 $0.00000 $0.03569
Sonnet 5 $0.00000 $0.01427
Haiku 4.5 $0.00000 $0.00714

Measured 2d ago against content hash 55b5087221f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

graph-based-agents scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Hidden instructionshighPrompt injection

Directives inside HTML comments, invisible characters or bidirectional overrides are read by the model and not by the person reviewing the file.

<!--- INCLUDE import ai.koog.agents.core.agent.AIAgent; import ai.koog.agents.core.agent.entity.AIAgentEdge; import ai.koog.agents.core.agent.entity.AIAgentGraphStrategy; import ai.koog.agents.core.agent.entity.AIAgentNo
Origin

This is a copy

89% identical to basic-agents — 986 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

docs/docs/agents/graph-based-agents.md · 804 lines

How it starts

The opening of the file, as written. The whole thing — 804 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Graph-based agents

With graph-based agents, you model the behavior as an explicit state machine: nodes of a graph strategy represent actions (LLM calls, tool execution) and edges represent data flow between nodes.

The main advantages of graph-based agents are:

  • Easy to visualize
  • State persistence
  • Composable architecture

??? note "Prerequisites"

--8<-- "quickstart-snippets.md:prerequisites"

--8<-- "quickstart-snippets.md:dependencies"

--8<-- "quickstart-snippets.md:api-key"

Examples on this page assume that you are running Llama 3.2 locally via Ollama.

This page describes how to re-create the strategy graph used by basic agents. It sends a request to an LLM and then either outputs the response (if the LLM responded with an assistant message) or executes a tool (if the LLM requested a tool call). In case of a tool call, the agent sends the tool result to the LLM and then either outputs the response or executes a tool.

Here is an illustration of the strategy graph:

---
config:
  flowchart:
    defaultRenderer: "elk"
---
graph TB
    subgraph nodeStart
        Input
    end
    
    subgraph nodeFinish
        Output
    end
    
    subgraph nodeSendInput
        llmRequest(Request LLM)
    end
    
    subgraph nodeExecuteTool
        executeTool(Execute tool call)
    end
    
    subgraph nodeSendToolResult
        sendToolResult(Request LLM)
    end
    
    Input --String--> llmRequest
    llmRequest --Message.Assistant--> onToolCalls{{onToolCalls}}
    llmRequest --Message.Assistant--> onTextMessage{{onTextMessage}}
    onTextMessage --String--> Output
    onToolCalls --ToolCalls--> executeTool --ReceivedToolResults--> sendToolResult
    sendToolResult --Message.Assistant--> onToolCalls
    sendToolResult --Message.Assistant--> onTextMessage

Build a strategy graph

In Koog, you implement a strategy using AIAgentGraphStrategyBuilder. Just like every node has an input and output type, the strategy as a whole also defines some input and output type. This example assumes that the input and output types are strings, which means the agent implementing this strategy will expect a string and return a string.

Read the full file on GitHub · 804 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 804 lines · 0 tokens per session scan C 55b5087221f9

Subscribe to this mod's changes

graph-based-agents is an agent published in the GitHub repository JetBrains/koog (4,553 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 7,137 tokens. A static security scan graded it C with 1 finding (hidden instructions). It is 89% identical to basic-agents, differing in 986 lines, and is treated as a copy.

Related

Other agents, from other repositories

agent-orchestration-context-manager

Elite AI context engineering specialist mastering dynamic context management, vector databases, knowledge graphs, and intelligent memory systems. Orchestrates context across multi-agent workflows, enterprise AI systems, and long-running projects with 2024/2025 best practices. Use PROACTIVELY for complex AI…

wshobson/agents · 66 tokens

backend-development-tdd-orchestrator

Master TDD orchestrator specializing in red-green-refactor discipline, multi-agent workflow coordination, and comprehensive test-driven development practices. Enforces TDD best practices across teams with AI-assisted testing and modern frameworks. Use PROACTIVELY for TDD implementation and governance.

wshobson/agents · 61 tokens

team-lead

Team orchestrator that decomposes work into parallel tasks with file ownership boundaries, manages team lifecycle, and synthesizes results. Use when coordinating multi-agent teams, decomposing complex tasks, or managing parallel workstreams.

wshobson/agents · 46 tokens

team-implementer

Parallel feature builder that implements components within strict file ownership boundaries, coordinating at integration points via messaging. Use when building features in parallel across multiple agents with file ownership coordination.

wshobson/agents · 38 tokens

integrator

Use for third-party integrations, API connections, webhooks, OAuth flows, and external service integration.

AgentWorkforce/relay · 23 tokens

lead

Use when coordinating multi-agent teams. Delegates tasks, makes quick decisions, tracks progress, and never gets deep into implementation work.

AgentWorkforce/relay · 28 tokens