Skip to content

Instantly share code, notes, and snippets.

@cszentkiralyi
Created May 7, 2026 23:56
Show Gist options
  • Select an option

  • Save cszentkiralyi/db8587ed8e8cb904e8be77148b3a02e7 to your computer and use it in GitHub Desktop.

Select an option

Save cszentkiralyi/db8587ed8e8cb904e8be77148b3a02e7 to your computer and use it in GitHub Desktop.
Qwen3.6 35B-A3B analysis of Dolorous via slop

Prompt: Map out the structure of this project, at a very high level. Describe the folder structure, the kinds of code that lives where, and a very short overview of how to run/build the project based on a package file or README. DO NOT read more than the top 20 lines of any particular file. Record your results in the file SLOP.md

Project Structure: Dolorous Code (dol)

Dolorous Code is an agentic development tool written in Go. It uses AI models (specifically Moonshot/OpenAI) to interact with a codebase autonomously, allowing the agent to read, write, and edit files within a sandboxed environment.

High-Level Overview

The project is a Go CLI application (main.go) that acts as a chat interface for an AI agent. The agent is equipped with "tools" (file reading, writing, editing, listing) to navigate and modify the project directory. It maintains a conversation history with the AI to plan and execute code changes.

Folder & File Structure

  • main.go: The entry point. Contains the main CLI loop, AI client initialization, tool definitions (file operations), and the agent logic that drives the conversation and tool execution.
  • go.mod / go.sum: Go module definitions. Dependencies include openai-go for AI interactions and jsonschema for generating tool parameters.
  • paths/: Contains paths.go and paths_test.go. Handles file system path operations and implements safety checks (sandboxing) to ensure the agent only accesses files within the allowed root directory.
  • tools/: Contains backlog.go, backlog_test.go, and tools.go. Provides additional agent utilities, such as managing a .dol/backlog.md file for tracking work items and other repository-specific tools.
  • docs/: Contains work-tracking.md, likely used for documenting the agent's progress or internal workflows.
  • patches/: Contains a patch file (0001-openai-go-extra-fields-on-request.patch), suggesting modifications to the openai-go dependency to support extra request fields.
  • vendor/: Vendored third-party dependencies.
  • dol.sublime-project: Sublime Text project configuration file.
  • README.md: Project documentation, including TODOs, references to AI agent architectures, and ANSI color codes used in the CLI.

How to Run / Build

  1. Environment: Ensure Go is installed. Set the MOONSHOT_API_KEY environment variable for the AI client to function.
  2. Build: Run go build in the project root to compile the binary.
  3. Run: Execute go run main.go or the compiled binary. The application will start an interactive chat session where you can provide tasks for the agent to perform on the codebase.

Prompt: What kind of features are implemented right now as far as agent tools & user-facing harness capabilities go?

Based on the code in main.go and the tools/ directory, here is a summary of the features currently implemented in Dolorous Code.

1. Agent Tools

The AI agent currently has access to four core file system tools, defined directly in main.go. These tools are sandboxed using the paths package to ensure the agent only operates within the allowed root directory.

  • file_read: Reads the contents of a specific file given a relative path.
  • file_write: Creates a new file with specified content.
    • Feature: Automatically creates parent directories if they don't exist.
    • Safety: Prevents overwriting existing files (requires file_edit for modifications).
  • file_edit: Edits an existing file by replacing a specific string (str_old) with a new one (str_new).
    • Feature: Supports replacing all occurrences or a specific count.
    • Safety: Validates that the old string exists before writing.
  • file_list: Lists files and directories recursively within a specified path (defaults to the current directory).
    • Output: Returns a JSON array of relative paths.

(Note: There is a tools/ package containing backlog.go and tools.go which defines a Tools struct and backlog management, but based on main.go, these are currently not imported or used in the active agent loop.)

2. User-Facing Harness Capabilities

The CLI harness (Agent.Run) provides an interactive chat interface with the following capabilities:

  • Interactive Chat Loop: Uses bufio.Scanner to read user input, maintaining a conversation history (context) passed to the AI model.
  • System Prompt: Currently hardcoded to prompt the AI as "Dolorous Loop", an autonomous implementation agent focused on converting documentation into code/tests.
  • Command Handling:
    • /quit, /exit, /done: Terminate the agent session.
    • :tool: (Placeholder) The code checks for this prefix but does not implement functionality yet.
  • Tool Execution: Automatically parses AI responses for tool calls, executes them using the registered tools, and feeds the results back into the conversation history without requiring user intervention.
  • Token Management:
    • Auto-Scaling: If the AI hits the max_completion_tokens limit (length finish reason), the harness doubles the token limit for the next turn to allow the response to complete.
  • Reasoning Support: Explicitly handles and forwards reasoning_content from the AI response (useful for models like o1 or R1 that output chain-of-thought).
  • Error Recovery: Tracks consecutive errors; if the agent fails twice in a row, it forces a prompt for user input to break the loop.
  • Visual Feedback: Uses ANSI color codes to distinguish between:
    • User input (> in blue)
    • AI response (< in yellow)
    • Tool usage (->tool in cyan, <-tool in red for errors)

Prompt (cancelled): Are there any obvious bugs where something is clearly going to fail at runtime?

Prompt: Actually, take a look at the agent loop specifically. How can it crash?

Based on the code in main.go, specifically the Agent.Run loop, there are a few potential runtime crashes (panics) depending on how the AI API responds or if internal state becomes inconsistent.

1. Nil Pointer Dereference on message

Location: Line 463

for _, choice := range message.Choices {

The Bug: The code checks for an error from runInference on line 452. However, if runInference were to return nil, nil (which is unlikely but possible with certain SDK versions or mocks), message would be nil. Accessing message.Choices would cause a fatal panic.

2. Nil Pointer Dereference on choice.Message

Location: Lines 464, 465, 486

param := choice.Message.ToParam()
reasoning_content, ok := choice.Message.JSON.ExtraFields["reasoning_content"]
// ...
for _, tool := range choice.Message.ToolCalls {

The Bug: The code assumes that if a choice exists, choice.Message is never nil. If the API returns a choice object where the Message field is missing or explicitly nil (e.g., in certain error responses or malformed completions), calling .ToParam(), .JSON, or .ToolCalls on it will cause a fatal panic.

3. Nil Pointer Dereference on choice.Message.JSON

Location: Line 465

reasoning_content, ok := choice.Message.JSON.ExtraFields["reasoning_content"]

The Bug: Even if choice.Message is valid, choice.Message.JSON might be nil if the SDK didn't populate it (e.g., if the response didn't contain extra JSON fields). Accessing .ExtraFields on a nil JSON pointer will cause a fatal panic.

4. Logic Bug: :tool Command Ignored

Location: Lines 443-445

} else if strings.HasPrefix(user_input, ":") {
    // :tool runs a defined tool
}

The Bug: If the user types :file_read, the code falls through to the inference step. The AI receives the :file_read command in the conversation history but has no special handler for it. The AI might hallucinate a response or try to interpret it as text, rather than executing the tool directly. This isn't a crash, but it's a broken feature.

5. Potential Type Mismatch (Compile Error)

Location: Line 448

params.MaxCompletionTokens = openai.Int(tokens_max)

The Bug: tokens_max is defined as int64 (line 30). If openai.Int expects an int (which is 32-bit on many systems), this will cause a compile-time error. If it accepts int64, it might return a *int64, which might not match the expected type for MaxCompletionTokens in the ChatCompletionNewParams struct, also causing a compile error.

Summary of Most Likely Crash

The most likely runtime crash is Scenario #2 (Nil choice.Message) if the API returns a response where the message structure is unexpected or empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment