8000 BREAKING CHANGE: messages -> query field in traj by klieret · Pull Request #1107 · SWE-agent/SWE-agent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BREAKING CHANGE: messages -> query field in traj #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of ser 8000 vice and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/usage/trajectories.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ Under the `trajectory` key, you can see information for every step of the agent.

```json
{
# This is the output of the LM
"response": "We are indeed seeing the same output as the issue. The issue suggests that we should look at line 1474 of the `fields.py`...",
# We then parse it into thoughts and actions
"thought": "We are indeed seeing the same output as the issue. The issue suggests that we should look at line 1474 of the `fields.py`..."
"action": "ls -F\n",
# And execute the action, resulting in the output
"observation": "AUTHORS.rst\nCHANGELOG.rst\nCODE_OF_CONDUCT.md...",
"response": "We are indeed seeing the same output as the issue. The issue suggests that we should look at line 1474 of the `fields.py`...",
# In addition, after the action was executed, state can be extracted from the environment
"state": "{\"open_file\": \"/marshmallow-code__marshmallow/reproduce.py\", \"working_dir\": \"/marshmallow-code__marshmallow\"}\n",
"thought": "We are indeed seeing the same output as the issue. The issue suggests that we should look at line 1474 of the `fields.py`..."
# For debugging, we also keep all messages that were shown to the LM
"query": [{"role": "system", "content": "You are a helpful assistant ..."}, ...]
},
```

!!! warning "Query and message field"
Prior to SWE-agent 1.1.0, we had a `message` field which corresponded (approximately) to the input
for the LM for the _next_ step. This was replaced with `query`, which shows the exact input
at the current step.

Here's a full example:

<details>
Expand Down
3 changes: 2 additions & 1 deletion sweagent/agent/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ def forward(self, history: list[dict[str, str]]) -> StepOutput:
# attributes (e.g., if we want to requery the model for a bash syntax error, we
# need to have the previous model output to format the requery template)
step = StepOutput()
step.query = copy.deepcopy(history)
try:
# Forward model and get actions
self._chook.on_model_query(messages=history, agent=self.name)
Expand Down Expand Up @@ -1181,7 +1182,7 @@ def add_step_to_trajectory(self, step: StepOutput) -> None:
8000 "thought": step.thought,
"execution_time": step.execution_time,
"state": step.state,
"messages": self.messages,
"query": step.query,
"extra_info": step.extra_info,
},
)
Expand Down
15 changes: 13 additions & 2 deletions sweagent/inspector/fileViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ function fetchFiles() {

function createTrajectoryItem(item, index) {
const elementId = `trajectoryItem${index}`;
const hasMessages = item.messages && item.messages.length > 0;

// Check for old format and log a warning
const isOldFormat = item.messages && !item.query;
if (isOldFormat) {
console.log(
`Found old format using 'messages' instead of 'query' in item ${index}`,
);
// Migrate old format to new format
item.query = item.messages;
}

const hasMessages = item.query && item.query.length > 0;

const escapeHtml = (text) => {
if (!text) {
Expand Down Expand Up @@ -71,7 +82,7 @@ function createTrajectoryItem(item, index) {
};

const messagesContent = hasMessages
? item.messages
? item.query
.map((msg, msgIndex) => {
let content = `----Item ${msgIndex}-----\n`;
content += `role: ${msg.role}\n`;
Expand Down
3 changes: 2 additions & 1 deletion sweagent/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class StepOutput(BaseModel):
query: list[dict] = [{}]
thought: str = ""
action: str = ""
output: str = ""
Expand Down Expand Up @@ -45,7 +46,7 @@ class TrajectoryStep(TypedDict):
state: dict[str, str]
thought: str
execution_time: float
messages: list[dict[str, Any]]
query: list[dict[str, Any]]
extra_info: dict[str, Any]


Expand Down
0