Skip to content

Commit

Permalink
fix error observation for command
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Jan 3, 2025
1 parent db274a1 commit f601e19
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions frontend/src/services/observations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export function handleObservationMessage(message: ObservationMessage) {
observation: "run" as const,
extras: {
command: String(message.extras.command || ""),
command_id: Number(message.extras.command_id || 0),
exit_code: Number(message.extras.exit_code || 0),
metadata: message.extras.metadata,
hidden: Boolean(message.extras.hidden),
},
}),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/state/chat-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const chatSlice = createSlice({
// Set success property based on observation type
if (observationID === "run") {
const commandObs = observation.payload as CommandObservation;
causeMessage.success = commandObs.extras.exit_code === 0;
causeMessage.success = commandObs.extras.metadata.exit_code === 0;
} else if (observationID === "run_ipython") {
// For IPython, we consider it successful if there's no error message
const ipythonObs = observation.payload as IPythonObservation;
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/types/core/observations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ export interface CommandObservation extends OpenHandsObservationEvent<"run"> {
source: "agent";
extras: {
command: string;
command_id: number;
exit_code: number;
hidden?: boolean;
metadata: Record<string, unknown>;
};
}

Expand Down
7 changes: 5 additions & 2 deletions frontend/src/types/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ export interface ObservationMessage {
// The observed data
content: string;

// Additional structured data
extras: Record<string, string>;
extras: {
metadata: Record<string, unknown>;
error_id: string;
[key: string]: string | Record<string, unknown>;
};

// A friendly message that can be put in the chat log
message: string;
Expand Down

0 comments on commit f601e19

Please sign in to comment.