RunCodeTask
Execute code snippets in an interactive environment with full oversight, working directory isolation, and output capture.
Side-Effect: Destructive
Interactive Review
Auto-Fix Supported
RunCodeTaskExecutionConfigData
JSON
{
"goal": "Find all .log files and summarize their size",
"workingDir": "./logs",
"task_type": "RunCode"
}
→
Session UI Output
Rendered
Code
Result
Output
new File(".").listFiles().findAll {
it.name.endsWith(".log")
}.sum { it.length() }
Result:
Output: Scanning directory... found 12 files.
10485760Output: Scanning directory... found 12 files.
Live Results Showcase
Explore actual artifacts and logs generated by the RunCodeTask in our test workspace.
Execution Configuration
These parameters define the specific goal and environment for a single task execution.
| Field | Type | Description |
|---|---|---|
goal * |
String | The specific task or goal to be accomplished via code execution. |
workingDir |
String | The relative file path of the working directory for the script. |
task_description |
String | Optional metadata describing the purpose of this specific execution. |
task_dependencies |
List<String> | List of task IDs that must complete before this execution. |
Task Lifecycle
- Initialization: Loads the specified
CodeRuntime(Groovy by default) and injects symbols. - Agent Planning: A
CodingTaskagent generates a solution based on thegoal. - Execution: The code is executed within the configured
workingDir. - Feedback Loop:
- Auto-Fix Mode: If
autoFixis true, the task executes and completes automatically. - Interactive Mode: The user reviews the code, result, and output, with options to Continue or Revise.
- Auto-Fix Mode: If
Type Configuration
| Field | Type | Default |
|---|---|---|
codeRuntime |
CodeRuntimes | GroovyRuntime |
model |
ApiChatModel | System Default |
Orchestration Boilerplate
Invoke RunCodeTask directly using the UnifiedHarness for automated agentic coding.
import com.simiacryptus.cognotik.plan.TaskType
import com.simiacryptus.cognotik.plan.tools.run.RunCodeTask.Companion.RunCode
import com.simiacryptus.cognotik.plan.tools.run.RunCodeTask.RunCodeTaskExecutionConfigData
// 1. Define Runtime Input
val executionConfig = RunCodeTaskExecutionConfigData(
goal = "Find all .log files and summarize their size",
workingDir = "./logs",
task_description = "Log Analysis"
)
// 2. Run via Harness
harness.runTask(
taskType = RunCode,
typeConfig = RunCodeTaskTypeConfig(codeRuntime = CodeRuntimes.GroovyRuntime),
executionConfig = executionConfig,
workspace = projectDir,
autoFix = true // Set to true for headless execution
)
LLM Prompt Segment
The following instructions are injected into the LLM context when this task is active:
RunCode - Use a groovy interpreter to solve and complete the user's request. * Do not directly write code (yet) * Include detailed technical requirements for the needed solution