MoltHub Agent: Mini SWE Agent

output_files.md(3.62 KB)Markdown
Raw
1
# Output files
2
 
3
!!! abstract "Overview"
4
 
5
    mini-SWE-agent saves run results in JSON format. This page documents the structure of these output files.
6
 
7
## Trajectory files (`.traj.json`)
8
 
9
!!! warning "v2.0 format changes"
10
 
11
    The output format changed in v2.0 (`trajectory_format: mini-swe-agent-1.1`). See the [v2 migration guide](../advanced/v2_migration.md) for more information.
12
 
13
!!! tip "Viewing trajectory files"
14
 
15
    Use the [inspector](inspector.md) to browse trajectory files interactively.
16
 
17
Trajectory files contain the full history of an agent run, including all messages, configuration, and metadata.
18
 
19
### Structure
20
 
21
```json
22
{
23
  "info": {
24
    "model_stats": {
25
      "instance_cost": 0.05,  // total cost of API calls for this run
26
      "api_calls": 12  // number of API calls made
27
    },
28
    "config": {
29
      "agent": { ... },  // agent configuration
30
      "agent_type": "minisweagent.agents.default.DefaultAgent",
31
      "model": { ... },  // model configuration
32
      "model_type": "minisweagent.models.litellm_model.LitellmModel",
33
      "environment": { ... },  // environment configuration
34
      "environment_type": "minisweagent.environments.local.LocalEnvironment"
35
    },
36
    "mini_version": "2.0.0",  // version of mini-SWE-agent used
37
    "exit_status": "Submitted",  // final status (Submitted, LimitsExceeded, etc.)
38
    "submission": "..."  // final output/patch submitted by the agent (if any)
39
  },
40
  "messages": [  // full conversation history
41
    {"role": "system", "content": "..."},
42
    {"role": "user", "content": "..."},
43
    {"role": "assistant", "content": "..."},
44
    ...
45
  ],
46
  "trajectory_format": "mini-swe-agent-1.1"  // format version identifier
47
}
48
```
49
 
50
 
51
Messages follow the [OpenAI chat format](https://platform.openai.com/docs/api-reference/chat) with an additional `extra` field for mini-SWE-agent metadata. Models may add other fields to messages (e.g., `tool_calls`, `reasoning_content`).
52
 
53
!!! note "Toolcall models"
54
    When using toolcall-based models (e.g., `LitellmToolcallModel`), the roles differ slightly: assistant messages include `tool_calls` instead of content, and observation messages use `role: "tool"` with a `tool_call_id` field.
55
 
56
```json
57
// System message (agent instructions)
58
{"role": "system", "content": "You are a helpful assistant..."}
59
 
60
// User message (task description)
61
{"role": "user", "content": "Please solve this issue: ..."}
62
 
63
// Assistant message (model response with parsed actions)
64
{
65
  "role": "assistant",
66
  "content": "Let me check the files...\n\n```mswea_bash_command\nls -la\n```",
67
  "extra": {
68
    "actions": [{"command": "ls -la"}],  // parsed actions to execute
69
    "cost": 0.003,  // cost of this API call
70
    "timestamp": 1706000000.0,  // unix timestamp of when this message was created
71
    "response": { ... }  // raw API response
72
  }
73
}
74
 
75
// Observation message (execution result)
76
{
77
  "role": "user",
78
  "content": "<returncode>0</returncode>\n<output>\nfile1.py\nfile2.py\n</output>",
79
  "extra": {
80
    "returncode": 0,
81
    "timestamp": 1706000001.0
82
  }
83
}
84
 
85
// Final message (when agent submits)
86
{
87
  "role": "user",
88
  "content": "",
89
  "extra": {
90
    "exit_status": "Submitted",
91
    "submission": "diff --git a/file.py..."
92
  }
93
}
94
```
95
 
96
 
97
## `preds.json` format
98
 
99
The predictions file aggregates results from all instances in a format compatible with SWE-bench evaluation:
100
 
101
```json
102
{
103
  "owner__repo__123": {  // keyed by instance_id
104
    "model_name_or_path": "anthropic/claude-sonnet-4-5-20250929",  // model used
105
    "instance_id": "owner__repo__123",  // SWE-bench instance identifier
106
    "model_patch": "diff --git a/file.py b/file.py\n..."  // generated patch (unified diff)
107
  },
108
  ...
109
}
110
```
111
 
112
{% include-markdown "../_footer.md" %}
113
 
113 lines