Artem Semidetnov
03/02/2026, 11:46 AMMark Murphy
03/02/2026, 11:54 AMKonstantin
03/02/2026, 12:47 PMVadim Briliantov
03/02/2026, 1:41 PMval coding by subgraphWithTask<String, String>(tools = codingTools, model = …, …) { input -> "You have to write the code to complete the task:\n $input" }
b. val verification by subgraphWithVerification(tools = verificationTools, model = …, …) { input -> "You have to verify that: 1. The code is compiling. 2. Tests pass. 3. The original problem is ACTUALLY solved as requested." }
3. And code the loop:
val codingStrategy by strategy<String, String>("coding") {
val coding by subgraphWithTask<String, String>(
tools = codingTools, model = …, …
) { input ->
"You have to write the code to complete the task:\n $input"
}
val verification by subgraphWithVerification<String, String>(
tools = verificationTools, model = …, …
) { input ->
"""You have to verify that:
1. The code is compiling.
2. Tests pass.
3. The original problem is ACTUALLY solved as requested
If something is wrong -- provide the feedback what has to be fixed or re-implemented.
"""
}
edge(nodeStart forwardTo coding)
edge(coding forwardTo verification)
edge(verification forwardTo nodeFinish onCondition { it.isSuccessful } transformed { it.input })
edge(verification forwardTo coding onCondition { !it.isSuccessful } transformed { it.feedback })
}
So, we’re continously running the verification step (with relevant verification tools, including code check, compillation, etc.) and either finishing the work if everything is alright or passing the feedback back to the coding stage (and this loop continous)Vadim Briliantov
03/02/2026, 1:42 PMVadim Briliantov
03/02/2026, 1:47 PMnodeLLMCompressHistory() — https://docs.koog.ai/history-compression/, ideally with RetrieveFactsFromHistory where you can state which specific facts or information are important for the next steps), otherwise verification step would see ALL actions (and intermediate attempts, tool calls, tool responses, file contents, etc.) of the coding stage, and vice versa.
So consider describing what is relevant and persisting only that information between logical subtasks.
Otherwise — you’ll be risking to consume the LLM context very fast when modifying large files.
See this article as a reference about the history compression (specifically for coding agent): https://blog.jetbrains.com/ai/2026/01/building-ai-agents-in-kotlin-part-5-teaching-agents-to-forget/
And this one about domain modeling and `subgraphWithTask`: https://medium.com/@vadim.briliantov/beyond-prompts-use-domain-models-to-rule-ai-agents-instead-89765faa6e46