Skip to content

🙌 OpenHands: AI-Driven Development

feat(chat): add /goal slash command with status banner (#1492)

Vasco Schiavo5aeccb878e9f
diff --git a/__tests__/components/chat/chat-interface.test.tsx b/__tests__/components/chat/chat-interface.test.tsx
index 5c09cc6bb5..7139fae2c8 100644
--- a/__tests__/components/chat/chat-interface.test.tsx
+++ b/__tests__/components/chat/chat-interface.test.tsx
@@ -34,6 +34,7 @@ import { useLoadOlderEvents } from "#/hooks/use-load-older-events";
import { useTaskPolling } from "#/hooks/query/use-task-polling";
import { AgentState } from "#/types/agent-state";
import { useConversationStore } from "#/stores/conversation-store";
+import { useGoalStore } from "#/stores/goal-store";
import { act } from "@testing-library/react";
const mockSend = vi.fn();
@@ -812,6 +813,74 @@ describe("ChatInterface - Auto-scroll on submit (issue #817)", () => {
expect(scrollWrites).toContain(10000);
});
});
+
+ it("follows the live goal banner into view when an active goal advances", async () => {
+ vi.mocked(useOptionalConversationId).mockReturnValue({
+ conversationId: "test-conversation-id",
+ });
+ useGoalStore.setState({ statusByConversation: {} });
+
+ render(
+ <QueryClientProvider client={queryClient}>
+ <MemoryRouter initialEntries={["/test-conversation-id"]}>
+ <Routes>
+ <Route path=":conversationId" element={<ChatInterface />} />
+ </Routes>
+ </MemoryRouter>
+ </QueryClientProvider>,
+ );
+
+ const scrollContainer = document.querySelector(
+ "[data-testid='chat-scroll-container']",
+ ) as HTMLElement | null;
+ expect(scrollContainer).not.toBeNull();
+
+ // Let the mount-time auto-scroll settle; the user stays pinned to the
+ // bottom (autoScroll=true) since we never simulate a scroll-up.
+ await new Promise((r) => {
+ setTimeout(r, 0);
+ });
+
+ const scrollWrites: number[] = [];
+ Object.defineProperty(scrollContainer!, "scrollTop", {
+ configurable: true,
+ get: () => 9200,
+ set: (value: number) => {
+ scrollWrites.push(value);
+ },
+ });
+ Object.defineProperty(scrollContainer!, "scrollHeight", {
+ configurable: true,
+ writable: true,
+ value: 10000,
+ });
+ Object.defineProperty(scrollContainer!, "clientHeight", {
+ configurable: true,
+ writable: true,
+ value: 800,
+ });
+ scrollWrites.length = 0;
+
+ // Act: an in-progress goal advances — a store update only, with no change
+ // to `renderableEvents` (in-progress goal events are filtered out).
+ act(() => {
+ useGoalStore.getState().setStatus("test-conversation-id", {
+ active: true,
+ status: "running",
+ iteration: 1,
+ max_iterations: 10,
+ objective: "make pytest pass",
+ verdict: { score: 0.5, complete: false, missing: "needs tests" },
+ });
+ });
+
+ // Assert: the bottom-following effect scrolled the banner into view.
+ // Without wiring the active goal status into that effect, scrollWrites
+ // would stay empty.
+ await waitFor(() => {
+ expect(scrollWrites).toContain(10000);
+ });
+ });
});
describe("ChatInterface - Status Indicator", () => {
diff --git a/__tests__/components/chat/goal-status-banner.test.tsx b/__tests__/components/chat/goal-status-banner.test.tsx
new file mode 100644
index 0000000000..9c51cfd01b
--- /dev/null
+++ b/__tests__/components/chat/goal-status-banner.test.tsx
@@ -0,0 +1,54 @@
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it } from "vitest";
+import { GoalStatusBanner } from "#/components/features/chat/goal-status-banner";
+import { useGoalStore } from "#/stores/goal-store";
+import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+
+const CONV = "conv-1";
+
+const makeStatus = (overrides: Partial<GoalStatus> = {}): GoalStatus => ({
+ active: true,
+ status: "running",
+ iteration: 1,
+ max_iterations: 10,
+ objective: "make pytest pass",
+ verdict: null,
+ ...overrides,
+});
+
+describe("<GoalStatusBanner />", () => {
+ beforeEach(() => {
+ useGoalStore.setState({ statusByConversation: {} });
+ });
+
+ it("renders nothing when there is no goal status", () => {
+ const { container } = render(<GoalStatusBanner conversationId={CONV} />);
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it("renders the live banner while the loop is active", () => {
+ useGoalStore.getState().setStatus(CONV, makeStatus());
+ render(<GoalStatusBanner conversationId={CONV} />);
+ expect(screen.getByTestId("goal-status")).toBeInTheDocument();
+ expect(screen.getByTestId("goal-spinner")).toBeInTheDocument();
+ });
+
+ it("renders nothing once the loop ends (the terminal status renders inline)", () => {
+ useGoalStore.getState().setStatus(
+ CONV,
+ makeStatus({
+ active: false,
+ status: "complete",
+ verdict: { score: 1, complete: true, missing: "" },
+ }),
+ );
+ const { container } = render(<GoalStatusBanner conversationId={CONV} />);
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it("does not render a status from another conversation", () => {
+ useGoalStore.getState().setStatus("other", makeStatus());
+ const { container } = render(<GoalStatusBanner conversationId={CONV} />);
+ expect(container).toBeEmptyDOMElement();
+ });
+});
diff --git a/__tests__/components/chat/goal-status-content.test.tsx b/__tests__/components/chat/goal-status-content.test.tsx
new file mode 100644
index 0000000000..979f9b4be5
--- /dev/null
+++ b/__tests__/components/chat/goal-status-content.test.tsx
@@ -0,0 +1,78 @@
+import { render, screen } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+import { GoalStatusContent } from "#/components/features/chat/goal-status-content";
+import { I18nKey } from "#/i18n/declaration";
+import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+
+const makeStatus = (overrides: Partial<GoalStatus> = {}): GoalStatus => ({
+ active: true,
+ status: "running",
+ iteration: 1,
+ max_iterations: 10,
+ objective: "make pytest pass",
+ verdict: null,
+ ...overrides,
+});
+
+describe("<GoalStatusContent />", () => {
+ it("shows the objective and a spinner while running", () => {
+ render(<GoalStatusContent status={makeStatus()} />);
+ expect(screen.getByText("make pytest pass")).toBeInTheDocument();
+ expect(screen.getByTestId("goal-spinner")).toBeInTheDocument();
+ expect(screen.queryByTestId("goal-done")).toBeNull();
+ expect(screen.queryByTestId("goal-ended")).toBeNull();
+ });
+
+ it("shows a green check when complete", () => {
+ render(
+ <GoalStatusContent
+ status={makeStatus({
+ active: false,
+ status: "complete",
+ verdict: { score: 1, complete: true, missing: "" },
+ })}
+ />,
+ );
+ expect(screen.getByTestId("goal-done")).toBeInTheDocument();
+ expect(screen.queryByTestId("goal-spinner")).toBeNull();
+ expect(screen.queryByTestId("goal-ended")).toBeNull();
+ });
+
+ it("shows a muted cross, not a check, when it ends without completing", () => {
+ render(
+ <GoalStatusContent
+ status={makeStatus({
+ active: false,
+ status: "capped",
+ verdict: { score: 0.7, complete: false, missing: "needs more tests" },
+ })}
+ />,
+ );
+ expect(screen.getByTestId("goal-ended")).toBeInTheDocument();
+ expect(screen.queryByTestId("goal-done")).toBeNull();
+ });
+
+ it("expands the judge's missing note for a terminal status", () => {
+ render(
+ <GoalStatusContent
+ status={makeStatus({
+ active: false,
+ status: "capped",
+ verdict: { score: 0.7, complete: false, missing: "needs more tests" },
+ })}
+ />,
+ );
+ expect(screen.getByText(I18nKey.GOAL$MISSING)).toBeInTheDocument();
+ });
+
+ it("keeps the missing note collapsed while running", () => {
+ render(
+ <GoalStatusContent
+ status={makeStatus({
+ verdict: { score: 0.5, complete: false, missing: "needs tests" },
+ })}
+ />,
+ );
+ expect(screen.queryByText(I18nKey.GOAL$MISSING)).toBeNull();
+ });
+});
diff --git a/__tests__/components/conversation-events/chat/event-content-helpers/should-render-event.test.ts b/__tests__/components/conversation-events/chat/event-content-helpers/should-render-event.test.ts
index bbccd64e74..7e5b00b7bf 100644
--- a/__tests__/components/conversation-events/chat/event-content-helpers/should-render-event.test.ts
+++ b/__tests__/components/conversation-events/chat/event-content-helpers/should-render-event.test.ts
@@ -11,6 +11,7 @@ import { StreamingDeltaEvent } from "#/types/agent-server/core/events/streaming-
import {
ActionEvent,
ObservationEvent,
+ OpenHandsEvent,
SecurityRisk,
} from "#/types/agent-server/core";
import { SwitchLLMAction } from "#/types/agent-server/core/base/action";
@@ -203,3 +204,77 @@ describe("shouldRenderEvent - SwitchLLM", () => {
).toBe(true);
});
});
+
+describe("shouldRenderEvent - /goal status updates", () => {
+ const makeGoalEvent = (active: boolean): OpenHandsEvent =>
+ ({
+ id: "goal-1",
+ kind: "ConversationStateUpdateEvent",
+ timestamp: "2024-01-01T00:00:00Z",
+ source: "environment",
+ key: "goal",
+ value: {
+ active,
+ status: active ? "running" : "complete",
+ iteration: 1,
+ max_iterations: 10,
+ objective: "make pytest pass",
+ verdict: null,
+ },
+ }) as unknown as OpenHandsEvent;
+
+ const makeStatsEvent = (): OpenHandsEvent =>
+ ({
+ id: "stats-1",
+ kind: "ConversationStateUpdateEvent",
+ timestamp: "2024-01-01T00:00:00Z",
+ source: "environment",
+ key: "stats",
+ value: {},
+ }) as unknown as OpenHandsEvent;
+
+ it("renders the terminal goal status inline", () => {
+ expect(shouldRenderEvent(makeGoalEvent(false))).toBe(true);
+ });
+
+ it("hides the in-progress goal status (shown by the live banner)", () => {
+ expect(shouldRenderEvent(makeGoalEvent(true))).toBe(false);
+ });
+
+ it("hides non-goal state updates", () => {
+ expect(shouldRenderEvent(makeStatsEvent())).toBe(false);
+ });
+});
+
+describe("shouldRenderEvent - /goal loop re-prompts", () => {
+ const makeUserMessage = (text: string): OpenHandsEvent =>
+ ({
+ id: "m1",
+ kind: "MessageEvent",
+ source: "user",
+ timestamp: "2024-01-01T00:00:00Z",
+ llm_message: { role: "user", content: [{ type: "text", text }] },
+ }) as unknown as OpenHandsEvent;
+
+ it("hides the per-round follow-up re-prompt", () => {
+ const followup = makeUserMessage(
+ "The goal is NOT yet complete (audit iteration 1).\nOutstanding: needs tests",
+ );
+ expect(shouldRenderEvent(followup)).toBe(false);
+ });
+
+ it("hides the resume re-prompt", () => {
+ expect(
+ shouldRenderEvent(
+ makeUserMessage("Resuming a goal that was paused or interrupted. ..."),
+ ),
+ ).toBe(false);
+ });
+
+ it("still renders the objective and ordinary user messages", () => {
+ expect(
+ shouldRenderEvent(makeUserMessage("create roman.py with to_roman(n)")),
+ ).toBe(true);
+ expect(shouldRenderEvent(makeUserMessage("hello"))).toBe(true);
+ });
+});
diff --git a/__tests__/components/features/chat/goal-status-content.test.tsx b/__tests__/components/features/chat/goal-status-content.test.tsx
new file mode 100644
index 0000000000..903d02d63c
--- /dev/null
+++ b/__tests__/components/features/chat/goal-status-content.test.tsx
@@ -0,0 +1,78 @@
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { GoalStatusContent } from "#/components/features/chat/goal-status-content";
+import { useGoalStore } from "#/stores/goal-store";
+import type { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+
+const stopGoal = vi.fn();
+const resumeGoal = vi.fn();
+const pauseConversation = vi.fn();
+
+vi.mock("#/hooks/mutation/conversation-mutation-utils", () => ({
+ stopGoal: (...a: unknown[]) => stopGoal(...a),
+ resumeGoal: (...a: unknown[]) => resumeGoal(...a),
+ pauseConversation: (...a: unknown[]) => pauseConversation(...a),
+}));
+vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "conv-1" }),
+}));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const status = (overrides: Partial<GoalStatus> = {}): GoalStatus =>
+ ({
+ active: false,
+ status: "interrupted",
+ iteration: 1,
+ max_iterations: 10,
+ objective: "do the thing",
+ verdict: null,
+ ...overrides,
+ }) as GoalStatus;
+
+describe("GoalStatusContent loop controls", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ stopGoal.mockResolvedValue(undefined);
+ resumeGoal.mockResolvedValue(undefined);
+ pauseConversation.mockResolvedValue(undefined);
+ useGoalStore.setState({ statusByConversation: {} });
+ });
+
+ it("Stop cancels the loop and interrupts the agent on an active goal", async () => {
+ render(
+ <GoalStatusContent
+ status={status({ active: true, status: "running" })}
+ />,
+ );
+ await userEvent.click(screen.getByTestId("goal-stop"));
+ await waitFor(() => expect(stopGoal).toHaveBeenCalledWith("conv-1"));
+ await waitFor(() =>
+ expect(pauseConversation).toHaveBeenCalledWith("conv-1"),
+ );
+ });
+
+ it("Resume continues an interrupted goal", async () => {
+ render(<GoalStatusContent status={status({ status: "interrupted" })} />);
+ await userEvent.click(screen.getByTestId("goal-resume"));
+ await waitFor(() => expect(resumeGoal).toHaveBeenCalledWith("conv-1"));
+ });
+
+ it("hides Resume while another goal is already active", () => {
+ useGoalStore.setState({
+ statusByConversation: {
+ "conv-1": status({ active: true, status: "running" }),
+ },
+ });
+ render(<GoalStatusContent status={status({ status: "interrupted" })} />);
+ expect(screen.queryByTestId("goal-resume")).toBeNull();
+ });
+
+ it("shows no controls for a completed goal", () => {
+ render(<GoalStatusContent status={status({ status: "complete" })} />);
+ expect(screen.queryByTestId("goal-stop")).toBeNull();
+ expect(screen.queryByTestId("goal-resume")).toBeNull();
+ });
+});
diff --git a/__tests__/hooks/chat/use-goal-interceptor.test.ts b/__tests__/hooks/chat/use-goal-interceptor.test.ts
new file mode 100644
index 0000000000..152bf85e06
--- /dev/null
+++ b/__tests__/hooks/chat/use-goal-interceptor.test.ts
@@ -0,0 +1,101 @@
+import { act, renderHook, waitFor } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { useGoalInterceptor } from "#/hooks/chat/use-goal-interceptor";
+
+const mockStartGoal = vi.hoisted(() =>
+ vi.fn<
+ (
+ id: string,
+ req: { objective: string; max_iterations?: number },
+ ) => Promise<void>
+ >(),
+);
+const mockToast = vi.hoisted(() => vi.fn<(message: string) => void>());
+
+vi.mock("#/hooks/mutation/conversation-mutation-utils", () => ({
+ startGoal: (
+ id: string,
+ req: { objective: string; max_iterations?: number },
+ ) => mockStartGoal(id, req),
+}));
+
+vi.mock("#/utils/custom-toast-handlers", () => ({
+ displayErrorToast: (message: string) => mockToast(message),
+}));
+
+const CONV = "conv-1";
+
+describe("useGoalInterceptor", () => {
+ beforeEach(() => {
+ mockStartGoal.mockReset();
+ mockStartGoal.mockResolvedValue(undefined);
+ mockToast.mockReset();
+ });
+
+ it("falls through to onSubmit for non-/goal messages", () => {
+ const onSubmit = vi.fn();
+ const { result } = renderHook(() => useGoalInterceptor(CONV, onSubmit));
+ act(() => result.current("hello world"));
+ expect(onSubmit).toHaveBeenCalledWith("hello world");
+ expect(mockStartGoal).not.toHaveBeenCalled();
+ });
+
+ it("intercepts /goal and starts the loop with the objective", () => {
+ const onSubmit = vi.fn();
+ const { result } = renderHook(() => useGoalInterceptor(CONV, onSubmit));
+ act(() => result.current("/goal make pytest pass"));
+ expect(onSubmit).not.toHaveBeenCalled();
+ expect(mockStartGoal).toHaveBeenCalledWith(CONV, {
+ objective: "make pytest pass",
+ });
+ });
+
+ it("parses a leading --max N flag", () => {
+ const { result } = renderHook(() => useGoalInterceptor(CONV, vi.fn()));
+ act(() => result.current("/goal --max 3 make pytest pass"));
+ expect(mockStartGoal).toHaveBeenCalledWith(CONV, {
+ objective: "make pytest pass",
+ max_iterations: 3,
+ });
+ });
+
+ it("parses the --max=N form", () => {
+ const { result } = renderHook(() => useGoalInterceptor(CONV, vi.fn()));
+ act(() => result.current("/goal --max=5 ship it"));
+ expect(mockStartGoal).toHaveBeenCalledWith(CONV, {
+ objective: "ship it",
+ max_iterations: 5,
+ });
+ });
+
+ it("ignores an invalid --max value and treats the rest as the objective", () => {
+ const { result } = renderHook(() => useGoalInterceptor(CONV, vi.fn()));
+ act(() => result.current("/goal --max abc do the thing"));
+ expect(mockStartGoal).toHaveBeenCalledWith(CONV, {
+ objective: "--max abc do the thing",
+ });
+ });
+
+ it("does nothing for a bare /goal with no objective", () => {
+ const onSubmit = vi.fn();
+ const { result } = renderHook(() => useGoalInterceptor(CONV, onSubmit));
+ act(() => result.current("/goal"));
+ expect(onSubmit).not.toHaveBeenCalled();
+ expect(mockStartGoal).not.toHaveBeenCalled();
+ });
+
+ it("falls through when conversationId is null", () => {
+ const onSubmit = vi.fn();
+ const { result } = renderHook(() => useGoalInterceptor(null, onSubmit));
+ act(() => result.current("/goal do it"));
+ expect(onSubmit).toHaveBeenCalledWith("/goal do it");
+ expect(mockStartGoal).not.toHaveBeenCalled();
+ });
+
+ it("shows an error toast when startGoal rejects", async () => {
+ mockStartGoal.mockRejectedValueOnce(new Error("boom"));
+ const { result } = renderHook(() => useGoalInterceptor(CONV, vi.fn()));
+ act(() => result.current("/goal do it"));
+ await waitFor(() => expect(mockToast).toHaveBeenCalledWith("boom"));
+ });
+});
diff --git a/__tests__/hooks/query/use-conversation-history.test.tsx b/__tests__/hooks/query/use-conversation-history.test.tsx
index 11547a673e..998e06cf97 100644
--- a/__tests__/hooks/query/use-conversation-history.test.tsx
+++ b/__tests__/hooks/query/use-conversation-history.test.tsx
@@ -290,7 +290,38 @@ describe("useConversationHistory cache key stability", () => {
// The hook now consistently uses searchEvents for all conversations.
});
- it("treats cached history as never stale (staleTime is Infinity)", async () => {
+ it("refetches the tail on remount (returning to a conversation) so events produced while away load in one batched page", async () => {
+ const v1Spy = vi.spyOn(EventService, "searchEvents");
+ v1Spy.mockResolvedValue(makePage([makeEvent()]));
+
+ vi.mocked(useUserConversation).mockReturnValue({
+ data: makeConversation("V1"),
+ isLoading: false,
+ isPending: false,
+ isError: false,
+ error: null,
+ refetch: vi.fn(),
+ } as any);
+
+ const { unmount } = renderHook(
+ () => useConversationHistory("conv-remount"),
+ { wrapper: localWrapper },
+ );
+ await waitFor(() => expect(v1Spy).toHaveBeenCalledTimes(1));
+
+ // Leaving keeps the page cached (gcTime), so returning renders instantly —
+ // but it MUST refetch the tail so events the agent produced while we were
+ // away (e.g. an active /goal loop emitting turns on another conversation)
+ // arrive in this one batched REST page instead of being back-filled one at
+ // a time over the WebSocket `since` replay.
+ unmount();
+ renderHook(() => useConversationHistory("conv-remount"), {
+ wrapper: localWrapper,
+ });
+ await waitFor(() => expect(v1Spy).toHaveBeenCalledTimes(2));
+ });
+
+ it("keeps the page cached (no window-focus refetch) so the gated WebSocket doesn't churn", async () => {
const v1Spy = vi.spyOn(EventService, "searchEvents");
v1Spy.mockResolvedValue(makePage([makeEvent()]));
@@ -304,7 +335,7 @@ describe("useConversationHistory cache key stability", () => {
} as any);
const { result } = renderHook(
- () => useConversationHistory("conv-stale-check"),
+ () => useConversationHistory("conv-focus-check"),
{ wrapper: localWrapper },
);
@@ -312,14 +343,17 @@ describe("useConversationHistory cache key stability", () => {
expect(result.current.data).toBeDefined();
});
- // Check the query's staleTime option in the cache
const queries = localQueryClient.getQueryCache().findAll({
- queryKey: ["conversation-history", "conv-stale-check"],
+ queryKey: ["conversation-history", "conv-focus-check"],
});
expect(queries).toHaveLength(1);
- expect((queries[0].options as Record<string, unknown>).staleTime).toBe(
- Infinity,
- );
+ const options = queries[0].options as Record<string, unknown>;
+ // Cached data renders instantly on return (gcTime), the tail refetches on
+ // mount, and window focus is a no-op — the socket connection is gated on
+ // this query settling, so a focus refetch would drop and reconnect it.
+ expect(options.gcTime).toBeGreaterThanOrEqual(30 * 60 * 1000);
+ expect(options.refetchOnMount).toBe("always");
+ expect(options.refetchOnWindowFocus).toBe(false);
});
it("has gcTime of at least 30 minutes for navigation resilience", async () => {
diff --git a/__tests__/stores/goal-store.test.ts b/__tests__/stores/goal-store.test.ts
new file mode 100644
index 0000000000..6113816fae
--- /dev/null
+++ b/__tests__/stores/goal-store.test.ts
@@ -0,0 +1,44 @@
+import { beforeEach, describe, expect, it } from "vitest";
+import { useGoalStore } from "#/stores/goal-store";
+import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+
+const CONV_A = "conv-a";
+const CONV_B = "conv-b";
+
+const statusFor = (conv: string) =>
+ useGoalStore.getState().statusByConversation[conv];
+
+const makeStatus = (overrides: Partial<GoalStatus> = {}): GoalStatus => ({
+ active: true,
+ status: "running",
+ iteration: 0,
+ max_iterations: 10,
+ objective: "make pytest pass",
+ verdict: null,
+ ...overrides,
+});
+
+describe("goal store", () => {
+ beforeEach(() => {
+ useGoalStore.setState({ statusByConversation: {} });
+ });
+
+ it("sets status scoped to the given conversation", () => {
+ const status = makeStatus();
+ useGoalStore.getState().setStatus(CONV_A, status);
+ expect(statusFor(CONV_A)).toEqual(status);
+ expect(statusFor(CONV_B)).toBeUndefined();
+ });
+
+ it("setStatus overwrites the previous status for a conversation", () => {
+ useGoalStore.getState().setStatus(CONV_A, makeStatus());
+ const next = makeStatus({
+ active: false,
+ status: "complete",
+ iteration: 2,
+ verdict: { score: 1, complete: true, missing: "" },
+ });
+ useGoalStore.getState().setStatus(CONV_A, next);
+ expect(statusFor(CONV_A)).toEqual(next);
+ });
+});
diff --git a/src/components/conversation-events/chat/event-content-helpers/should-render-event.ts b/src/components/conversation-events/chat/event-content-helpers/should-render-event.ts
index 394ca9eb46..f3001db297 100644
--- a/src/components/conversation-events/chat/event-content-helpers/should-render-event.ts
+++ b/src/components/conversation-events/chat/event-content-helpers/should-render-event.ts
@@ -1,19 +1,48 @@
-import { OpenHandsEvent } from "#/types/agent-server/core";
+import { MessageEvent, OpenHandsEvent } from "#/types/agent-server/core";
import {
isActionEvent,
isObservationEvent,
isMessageEvent,
isAgentErrorEvent,
isConversationStateUpdateEvent,
+ isGoalConversationStateUpdateEvent,
isHookExecutionEvent,
isACPToolCallEvent,
isStreamingDeltaEvent,
} from "#/types/agent-server/type-guards";
+// Prefixes of the SDK goal-loop re-prompts (FOLLOWUP_PROMPT / RESUME_PROMPT in
+// openhands.sdk .../conversation/goal/prompts.py). The goal loop injects these
+// as `user` messages each round to steer the agent, and FOLLOWUP_PROMPT embeds
+// the judge's verdict — which the goal banner already surfaces. The persisted
+// event carries no marker distinguishing them from real user input, so we match
+// the prompt text to keep this machinery out of the chat. Brittle by design;
+// keep in sync with the SDK prompts (the durable fix is a persisted goal-loop
+// flag on the event).
+const GOAL_REPROMPT_PREFIXES = [
+ "The goal is NOT yet complete (audit iteration",
+ "Resuming a goal that was paused or interrupted.",
+];
+
+const isGoalLoopReprompt = (event: MessageEvent): boolean => {
+ if (event.llm_message?.role !== "user") return false;
+ const content = event.llm_message.content;
+ const text = Array.isArray(content)
+ ? content
+ .filter((c) => c.type === "text")
+ .map((c) => c.text)
+ .join("\n")
+ : "";
+ return GOAL_REPROMPT_PREFIXES.some((prefix) => text.startsWith(prefix));
+};
+
export const shouldRenderEvent = (event: OpenHandsEvent) => {
- // Explicitly exclude system events that should not be rendered in chat
if (isConversationStateUpdateEvent(event)) {
- return false;
+ // A finished `/goal` loop renders inline so it settles into the
+ // conversation; the live (active) banner is shown separately by
+ // GoalStatusBanner, and all other state updates (and the in-progress goal
+ // events) stay hidden.
+ return isGoalConversationStateUpdateEvent(event) && !event.value.active;
}
// Render action events (with filtering)
@@ -59,9 +88,11 @@ export const shouldRenderEvent = (event: OpenHandsEvent) => {
return true;
}
- // Render message events (user and assistant messages)
+ // Render message events (user and assistant messages), except the goal loop's
+ // injected re-prompts — the judge feedback they carry is shown in the goal
+ // banner, so otherwise they leak into the chat as fake user turns.
if (isMessageEvent(event)) {
- return true;
+ return !isGoalLoopReprompt(event);
}
// Render agent error events
diff --git a/src/components/conversation-events/chat/event-message.tsx b/src/components/conversation-events/chat/event-message.tsx
index e90c3e669b..291ab419a1 100644
--- a/src/components/conversation-events/chat/event-message.tsx
+++ b/src/components/conversation-events/chat/event-message.tsx
@@ -17,12 +17,15 @@ import {
isHookExecutionEvent,
isACPToolCallEvent,
isStreamingDeltaEvent,
+ isConversationStateUpdateEvent,
+ isGoalConversationStateUpdateEvent,
} from "#/types/agent-server/type-guards";
import { useConfig } from "#/hooks/query/use-config";
import { useConversationStore } from "#/stores/conversation-store";
import { useAgentState } from "#/hooks/use-agent-state";
import { AgentState } from "#/types/agent-state";
import { ChatMessage } from "#/components/features/chat/chat-message";
+import { GoalStatusContent } from "#/components/features/chat/goal-status-content";
import { PlanPreview } from "../../features/chat/plan-preview";
import { ErrorEventMessage } from "./event-message-components/error-event-message";
import { UserAssistantEventMessage } from "./event-message-components/user-assistant-event-message";
@@ -159,6 +162,16 @@ export function EventMessage({
isFromPlanningAgent,
};
+ // Finished `/goal` loop: render the terminal status inline so it settles into
+ // the conversation. should-render-event.ts only lets the terminal goal event
+ // through; the active loop is shown by the separate bottom GoalStatusBanner.
+ if (
+ isConversationStateUpdateEvent(event) &&
+ isGoalConversationStateUpdateEvent(event)
+ ) {
+ return <GoalStatusContent status={event.value} />;
+ }
+
// Agent error events
if (isAgentErrorEvent(event)) {
return <ErrorEventMessage event={event} {...commonProps} />;
diff --git a/src/components/features/chat/chat-interface.tsx b/src/components/features/chat/chat-interface.tsx
index 345ed5012b..17d88c7ff9 100644
--- a/src/components/features/chat/chat-interface.tsx
+++ b/src/components/features/chat/chat-interface.tsx
@@ -6,8 +6,10 @@ import { isAcpAuthErrorCode } from "#/utils/acp-error-codes";
import { convertImageToBase64 } from "#/utils/convert-image-to-base-64";
import { createChatMessage } from "#/services/chat-service";
import { BtwMessages } from "./btw-messages";
+import { GoalStatusBanner } from "./goal-status-banner";
import { ModelMessages } from "./model-messages";
import { useModelStore } from "#/stores/model-store";
+import { useGoalStore } from "#/stores/goal-store";
import { InteractiveChatBox } from "./interactive-chat-box";
import { AgentState } from "#/types/agent-state";
import { useFilteredEvents } from "#/hooks/use-filtered-events";
@@ -149,6 +151,18 @@ export function ChatInterface() {
const { selectedRepository, replayJson } = useInitialQueryStore();
const { conversationId } = useOptionalConversationId();
+
+ // The live goal banner renders in the scroll stream but advances via store
+ // updates (in-progress goal events are filtered out of `renderableEvents`),
+ // so the bottom-following effect would not react to it. This key changes as
+ // an active loop appears and advances each round; feeding it into that effect
+ // keeps the banner in view when the user is pinned to the bottom.
+ const activeGoalScrollKey = useGoalStore((s) => {
+ const goal = conversationId
+ ? s.statusByConversation[conversationId]
+ : undefined;
+ return goal?.active ? `${goal.iteration}:${goal.status}` : null;
+ });
const { mutateAsync: uploadFiles } = useUnifiedUploadFiles();
// Lazy "scroll up to load older events" backfill. Initial REST fetch only
@@ -390,7 +404,12 @@ export function ChatInterface() {
}
// Note: We intentionally exclude autoScroll from deps because we only want
// to scroll when message content changes, not when autoScroll state changes.
- }, [renderableEvents.length, hasPendingUserMessages, scrollDomToBottom]);
+ }, [
+ renderableEvents.length,
+ hasPendingUserMessages,
+ activeGoalScrollKey,
+ scrollDomToBottom,
+ ]);
// Auto-load older events when the chat content doesn't overflow the
// scroll area (no scrollbar to drag, no wheel events past 0). We
@@ -534,6 +553,10 @@ export function ChatInterface() {
double-renders alongside the real event list.
*/}
<PendingUserMessages />
+
+ {/* Goal-loop status sits at the end of the message flow — above the
+ composer and its typing indicator — so progress stays in view. */}
+ <GoalStatusBanner conversationId={conversationId} />
</div>
<div className="flex shrink-0 flex-col gap-[6px] pb-4">
diff --git a/src/components/features/chat/goal-status-banner.tsx b/src/components/features/chat/goal-status-banner.tsx
new file mode 100644
index 0000000000..2ce2c978cd
--- /dev/null
+++ b/src/components/features/chat/goal-status-banner.tsx
@@ -0,0 +1,24 @@
+import { useGoalStore } from "#/stores/goal-store";
+import { GoalStatusContent } from "./goal-status-content";
+
+export interface GoalStatusBannerProps {
+ conversationId: string | null | undefined;
+}
+
+/**
+ * Live, bottom-pinned banner for an *active* `/goal` loop, fed by goal
+ * ConversationStateUpdateEvents (see useGoalStore). Once the loop ends it hides:
+ * the final status is rendered inline in the message timeline instead (see
+ * event-message.tsx + should-render-event.ts), so the finished goal settles into
+ * the conversation and later messages append below it.
+ */
+export function GoalStatusBanner({ conversationId }: GoalStatusBannerProps) {
+ const statusByConversation = useGoalStore((s) => s.statusByConversation);
+ const status = conversationId
+ ? statusByConversation[conversationId]
+ : undefined;
+
+ if (!status?.active) return null;
+
+ return <GoalStatusContent status={status} />;
+}
diff --git a/src/components/features/chat/goal-status-content.tsx b/src/components/features/chat/goal-status-content.tsx
new file mode 100644
index 0000000000..dea4701bc3
--- /dev/null
+++ b/src/components/features/chat/goal-status-content.tsx
@@ -0,0 +1,169 @@
+import { useState, type ReactNode } from "react";
+import { useTranslation } from "react-i18next";
+import CheckCircle from "#/icons/check-circle-solid.svg?react";
+import XCircle from "#/icons/x-circle-solid.svg?react";
+import { I18nKey } from "#/i18n/declaration";
+import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+import { useGoalStore } from "#/stores/goal-store";
+import { useOptionalConversationId } from "#/hooks/use-conversation-id";
+import {
+ pauseConversation,
+ resumeGoal,
+ stopGoal,
+} from "#/hooks/mutation/conversation-mutation-utils";
+import { displayErrorToast } from "#/utils/custom-toast-handlers";
+import { cn } from "#/utils/utils";
+import {
+ chatInputPillButtonClassName,
+ formControlDisabledClassName,
+} from "#/utils/form-control-classes";
+import { GenericEventMessage } from "./generic-event-message";
+
+const STATUS_LABEL_KEY: Record<GoalStatus["status"], I18nKey> = {
+ running: I18nKey.GOAL$STATUS_RUNNING,
+ complete: I18nKey.GOAL$STATUS_COMPLETE,
+ capped: I18nKey.GOAL$STATUS_CAPPED,
+ interrupted: I18nKey.GOAL$STATUS_INTERRUPTED,
+};
+
+/**
+ * Goal-status row: objective, round count, status word, the judge's score, the
+ * judge's "missing" note (expandable), and an indicator — spinner while running,
+ * green check when complete, muted cross when it ends without completing
+ * (capped/interrupted).
+ *
+ * Also exposes the loop controls at the end of the row: a Stop button while the
+ * loop is active and a Resume button once it is interrupted. Stop both cancels
+ * the loop (`stopGoal`) and interrupts the conversation, because the backend's
+ * stop deliberately leaves the in-flight agent turn running.
+ *
+ * Used in two places: the live bottom banner (GoalStatusBanner) while a loop is
+ * active, and inline in the message timeline for the terminal status, so a
+ * finished `/goal` settles into the conversation. Because the inline copy mounts
+ * fresh once terminal, `initiallyExpanded={!active}` expands the note there
+ * without any re-mount trickery.
+ */
+export function GoalStatusContent({ status }: { status: GoalStatus }) {
+ const { t } = useTranslation("openhands");
+ const { conversationId } = useOptionalConversationId();
+ // Whether *some* goal loop is currently live for this conversation. Used to
+ // hide a stale inline Resume button once the user has resumed (or started a
+ // new goal): resuming again would just 409 on the backend.
+ const goalActive = useGoalStore((s) =>
+ conversationId
+ ? Boolean(s.statusByConversation[conversationId]?.active)
+ : false,
+ );
+ const [pending, setPending] = useState(false);
+ const {
+ active,
+ objective,
+ iteration,
+ max_iterations: maxIterations,
+ verdict,
+ } = status;
+ const scorePct = verdict ? Math.round(verdict.score * 100) : null;
+ const details = verdict?.missing
+ ? t(I18nKey.GOAL$MISSING, { missing: verdict.missing })
+ : "";
+
+ const runAction = async (
+ action: (id: string) => Promise<void>,
+ failKey: I18nKey,
+ ) => {
+ if (!conversationId || pending) return;
+ setPending(true);
+ try {
+ await action(conversationId);
+ } catch (err) {
+ displayErrorToast(
+ err instanceof Error && err.message ? err.message : t(failKey),
+ );
+ } finally {
+ setPending(false);
+ }
+ };
+
+ // stopGoal only cancels the loop; the backend leaves the current agent turn
+ // running, so interrupt the conversation too to actually halt it.
+ const handleStop = () =>
+ runAction(async (id) => {
+ await stopGoal(id);
+ await pauseConversation(id);
+ }, I18nKey.GOAL$STOP_FAILED);
+
+ const handleResume = () => runAction(resumeGoal, I18nKey.GOAL$RESUME_FAILED);
+
+ let actionButton: ReactNode = null;
+ if (conversationId && active) {
+ actionButton = (
+ <button
+ type="button"
+ data-testid="goal-stop"
+ disabled={pending}
+ onClick={handleStop}
+ className={cn(
+ chatInputPillButtonClassName,
+ formControlDisabledClassName,
+ )}
+ >
+ {t(I18nKey.GOAL$STOP)}
+ </button>
+ );
+ } else if (conversationId && status.status === "interrupted" && !goalActive) {
+ actionButton = (
+ <button
+ type="button"
+ data-testid="goal-resume"
+ disabled={pending}
+ onClick={handleResume}
+ className={cn(
+ chatInputPillButtonClassName,
+ formControlDisabledClassName,
+ )}
+ >
+ {t(I18nKey.GOAL$RESUME)}
+ </button>
+ );
+ }
+
+ return (
+ <div data-testid="goal-status" className="flex flex-col w-full">
+ <GenericEventMessage
+ title={
+ <span className="flex items-center gap-2 flex-wrap">
+ <span className="opacity-60">{t(I18nKey.GOAL$PREFIX)}</span>
+ <span>{objective}</span>
+ <span className="opacity-60">
+ {t(I18nKey.GOAL$ROUND, { iteration, max: maxIterations })}
+ </span>
+ <span>{t(STATUS_LABEL_KEY[status.status])}</span>
+ {scorePct !== null && (
+ <span className="opacity-60">
+ {t(I18nKey.GOAL$SCORE, { score: scorePct })}
+ </span>
+ )}
+ {active ? (
+ <span
+ data-testid="goal-spinner"
+ className="inline-block w-3.5 h-3.5 ml-1 rounded-full border-2 border-transparent border-t-[var(--oh-border-input)] animate-spin"
+ />
+ ) : status.status === "complete" ? (
+ <span data-testid="goal-done" className="inline-flex ml-1">
+ <CheckCircle className="w-3.5 h-3.5 fill-success" />
+ </span>
+ ) : (
+ <span data-testid="goal-ended" className="inline-flex ml-1">
+ <XCircle className="w-3.5 h-3.5 fill-[var(--oh-muted)]" />
+ </span>
+ )}
+ </span>
+ }
+ titleTrailing={actionButton}
+ details={details}
+ initiallyExpanded={!active}
+ chevronPosition="before"
+ />
+ </div>
+ );
+}
diff --git a/src/components/features/chat/interactive-chat-box.tsx b/src/components/features/chat/interactive-chat-box.tsx
index b65cd686c3..b5fa7eb550 100644
--- a/src/components/features/chat/interactive-chat-box.tsx
+++ b/src/components/features/chat/interactive-chat-box.tsx
@@ -1,5 +1,6 @@
import { CustomChatInput } from "./custom-chat-input";
import { useBtwInterceptor } from "#/hooks/chat/use-btw-interceptor";
+import { useGoalInterceptor } from "#/hooks/chat/use-goal-interceptor";
import { useModelInterceptor } from "#/hooks/chat/use-model-interceptor";
import { useChatAttachmentUpload } from "#/hooks/chat/use-chat-attachment-upload";
import { AgentState } from "#/types/agent-state";
@@ -41,7 +42,7 @@ export function InteractiveChatBox({
const { handleUpload } = useChatAttachmentUpload();
- const handleAfterModel = useBtwInterceptor(conversationId, (message) => {
+ const handleAfterGoal = useBtwInterceptor(conversationId, (message) => {
const { imagesToEmbed, imagesAsFiles } = partitionImagesForUpload(
images,
imagesMarkedUploadAsFile,
@@ -49,6 +50,7 @@ export function InteractiveChatBox({
onSubmit(message, imagesToEmbed, [...files, ...imagesAsFiles]);
clearAllFiles();
});
+ const handleAfterModel = useGoalInterceptor(conversationId, handleAfterGoal);
const handleSubmit = useModelInterceptor(conversationId, handleAfterModel);
const handleSuggestionsClick = (suggestion: string) => {
diff --git a/src/contexts/conversation-websocket-context.tsx b/src/contexts/conversation-websocket-context.tsx
index ed8bc691e1..44da40624f 100644
--- a/src/contexts/conversation-websocket-context.tsx
+++ b/src/contexts/conversation-websocket-context.tsx
@@ -20,6 +20,7 @@ import { useOptimisticUserMessageStore } from "#/stores/optimistic-user-message-
import { useConversationStateStore } from "#/stores/conversation-state-store";
import { useCommandStore } from "#/stores/command-store";
import { useBrowserStore } from "#/stores/browser-store";
+import { useGoalStore } from "#/stores/goal-store";
import {
isAgentServerEvent,
isAgentErrorEvent,
@@ -29,6 +30,7 @@ import {
isFullStateConversationStateUpdateEvent,
isAgentStatusConversationStateUpdateEvent,
isStatsConversationStateUpdateEvent,
+ isGoalConversationStateUpdateEvent,
isExecuteBashActionEvent,
isExecuteBashObservationEvent,
isDisplayableErrorEvent,
@@ -225,9 +227,14 @@ export function ConversationWebSocketProvider({
const {
data: preloadedHistory,
isPending: isPreloadingHistory,
+ isFetching: isFetchingHistory,
isError: isPreloadHistoryError,
} = useConversationHistory(conversationId);
+ // Skeleton only on the genuine first load (no cached data yet). On return the
+ // cached page is present, so `isPending` is false and we render the
+ // last-known discussion immediately while the tail refetch runs in the
+ // background — see the socket gate below, which waits on `isFetching`.
const isLoadingHistoryMain = !!conversationId && isPreloadingHistory;
// Clear the (global, not conversation-scoped) event store when the active
@@ -298,35 +305,42 @@ export function ConversationWebSocketProvider({
* (we hold the WS connection open until then to avoid an `all` resend).
*/
const initialAfterTimestamp = useMemo<string | null>(() => {
- if (isPreloadingHistory) return null;
+ // Wait for the history query to settle — including the refetch fired when
+ // returning to a conversation — so we anchor `since` to the freshest event
+ // we have rather than a stale cached tail.
+ if (isFetchingHistory) return null;
const events = preloadedHistory?.events ?? [];
const latest = events[events.length - 1];
if (!latest || !("timestamp" in latest) || !latest.timestamp) return null;
return latest.timestamp;
- }, [preloadedHistory, isPreloadingHistory]);
+ }, [preloadedHistory, isFetchingHistory]);
// Build WebSocket URL from props.
//
- // We deliberately wait for the initial REST history fetch to settle before
- // opening the socket so the WS subscription can use `resend_mode='since'`
- // with a meaningful `after_timestamp`. Without this gate, the WS would open
- // immediately and either replay the entire conversation (when falling back
- // to `resend_mode='all'`) or miss events that arrived between REST and WS.
+ // We deliberately wait for the history fetch to settle before opening the
+ // socket so the WS subscription can use `resend_mode='since'` with a
+ // meaningful `after_timestamp`. This gate is on `isFetching`, not just the
+ // first-load `isPending`, so the refetch fired when returning to a
+ // conversation also completes first: the socket bakes `after_timestamp` into
+ // its URL at connect time and will NOT re-subscribe when the value changes
+ // later (see use-websocket — options live in a ref, reconnect keys on the URL
+ // only). Connecting mid-fetch would therefore pin `since` to the stale cached
+ // tail and replay the entire backlog over the socket. Without any gate the WS
+ // would instead fall back to `resend_mode='all'`. If the REST query errored we
+ // fall through and connect with `resend_mode='all'` so the user still sees
+ // live events.
const wsUrl = useMemo(() => {
if (!conversationId || !conversationUrl) {
return null;
}
- // Don't connect while we're still fetching the initial history. If the
- // REST query errored we fall through and connect with `resend_mode='all'`
- // so the user still sees live events.
- if (isPreloadingHistory && !isPreloadHistoryError) {
+ if (isFetchingHistory && !isPreloadHistoryError) {
return null;
}
return buildWebSocketUrl(conversationId, conversationUrl);
}, [
conversationId,
conversationUrl,
- isPreloadingHistory,
+ isFetchingHistory,
isPreloadHistoryError,
]);
@@ -548,6 +562,12 @@ export function ConversationWebSocketProvider({
if (isStatsConversationStateUpdateEvent(event)) {
updateMetricsFromStats(event);
}
+ // Mirror goal status into the store. Intentionally duplicated across
+ // the main and planning WebSocket handlers (like the execution_status
+ // and stats branches above), not a merge artifact.
+ if (isGoalConversationStateUpdateEvent(event) && conversationId) {
+ useGoalStore.getState().setStatus(conversationId, event.value);
+ }
}
// Handle ExecuteBashAction events - add command as input to terminal
@@ -744,6 +764,12 @@ export function ConversationWebSocketProvider({
if (isStatsConversationStateUpdateEvent(event)) {
updateMetricsFromStats(event);
}
+ // Mirror goal status into the store. Intentionally duplicated across
+ // the main and planning WebSocket handlers (like the execution_status
+ // and stats branches above), not a merge artifact.
+ if (isGoalConversationStateUpdateEvent(event) && conversationId) {
+ useGoalStore.getState().setStatus(conversationId, event.value);
+ }
}
// Handle ExecuteBashAction events - add command as input to terminal
diff --git a/src/hooks/chat/use-goal-interceptor.test.ts b/src/hooks/chat/use-goal-interceptor.test.ts
new file mode 100644
index 0000000000..0fb09d8af7
--- /dev/null
+++ b/src/hooks/chat/use-goal-interceptor.test.ts
@@ -0,0 +1,81 @@
+import { renderHook } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { useGoalInterceptor } from "./use-goal-interceptor";
+
+const startGoal = vi.fn();
+const displayErrorToast = vi.fn();
+
+vi.mock("#/hooks/mutation/conversation-mutation-utils", () => ({
+ startGoal: (...args: unknown[]) => startGoal(...args),
+}));
+vi.mock("#/utils/custom-toast-handlers", () => ({
+ displayErrorToast: (...args: unknown[]) => displayErrorToast(...args),
+}));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const CONV = "conv-1";
+
+const setup = (conversationId: string | null) => {
+ const onSubmit = vi.fn();
+ const { result } = renderHook(() =>
+ useGoalInterceptor(conversationId, onSubmit),
+ );
+ return { intercept: result.current, onSubmit };
+};
+
+describe("useGoalInterceptor", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ startGoal.mockResolvedValue(undefined);
+ });
+
+ it("passes a non-goal message straight through to onSubmit", () => {
+ const { intercept, onSubmit } = setup(CONV);
+ intercept("hello there");
+ expect(onSubmit).toHaveBeenCalledWith("hello there");
+ expect(startGoal).not.toHaveBeenCalled();
+ });
+
+ it("toasts and starts nothing for a bare /goal (no objective)", () => {
+ const { intercept, onSubmit } = setup(CONV);
+ intercept("/goal");
+ expect(displayErrorToast).toHaveBeenCalledWith("GOAL$OBJECTIVE_REQUIRED");
+ expect(startGoal).not.toHaveBeenCalled();
+ expect(onSubmit).not.toHaveBeenCalled();
+ });
+
+ it("toasts for a flag-only /goal with no objective", () => {
+ const { intercept } = setup(CONV);
+ intercept("/goal --max 5");
+ expect(displayErrorToast).toHaveBeenCalledWith("GOAL$OBJECTIVE_REQUIRED");
+ expect(startGoal).not.toHaveBeenCalled();
+ });
+
+ it("starts a goal loop with the objective", () => {
+ const { intercept } = setup(CONV);
+ intercept("/goal build a hello world script");
+ expect(startGoal).toHaveBeenCalledWith(CONV, {
+ objective: "build a hello world script",
+ });
+ expect(displayErrorToast).not.toHaveBeenCalled();
+ });
+
+ it("parses a leading --max flag into max_iterations", () => {
+ const { intercept } = setup(CONV);
+ intercept("/goal --max 3 build it");
+ expect(startGoal).toHaveBeenCalledWith(CONV, {
+ objective: "build it",
+ max_iterations: 3,
+ });
+ });
+
+ it("passes through (no toast, no loop) when there is no conversation", () => {
+ const { intercept, onSubmit } = setup(null);
+ intercept("/goal");
+ expect(onSubmit).toHaveBeenCalledWith("/goal");
+ expect(startGoal).not.toHaveBeenCalled();
+ expect(displayErrorToast).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/hooks/chat/use-goal-interceptor.ts b/src/hooks/chat/use-goal-interceptor.ts
new file mode 100644
index 0000000000..25946da062
--- /dev/null
+++ b/src/hooks/chat/use-goal-interceptor.ts
@@ -0,0 +1,65 @@
+import { useCallback } from "react";
+import { useTranslation } from "react-i18next";
+import type { StartGoalRequest } from "@openhands/typescript-client";
+import { startGoal } from "#/hooks/mutation/conversation-mutation-utils";
+import { displayErrorToast } from "#/utils/custom-toast-handlers";
+import { I18nKey } from "#/i18n/declaration";
+import { GOAL_COMMAND } from "#/utils/constants";
+
+const GOAL_PREFIX = `${GOAL_COMMAND} `;
+
+/** Optional leading "--max <n>" (or "--max=<n>") flag that caps the audit rounds. */
+const MAX_FLAG = /^--max(?:=|\s+)(\d+)\s*/;
+
+/**
+ * Intercepts "/goal [--max N] <objective>" submissions and starts a goal loop
+ * on the agent server: it pursues the objective, judging completion after each
+ * run until done or the cap is reached. Live progress streams back as goal
+ * ConversationStateUpdateEvents (rendered by GoalStatusBanner). Everything else
+ * falls through to `onSubmit`. Passthrough when `conversationId` is null.
+ */
+export const useGoalInterceptor = (
+ conversationId: string | null | undefined,
+ onSubmit: (message: string) => void,
+) => {
+ const { t } = useTranslation();
+
+ return useCallback(
+ (message: string) => {
+ const trimmed = message.trim();
+ const isGoal =
+ trimmed === GOAL_COMMAND || trimmed.startsWith(GOAL_PREFIX);
+ if (!conversationId || !isGoal) {
+ onSubmit(message);
+ return;
+ }
+
+ let rest = trimmed.slice(GOAL_COMMAND.length).trim();
+ let maxIterations: number | undefined;
+ const maxMatch = rest.match(MAX_FLAG);
+ if (maxMatch) {
+ maxIterations = parseInt(maxMatch[1], 10);
+ rest = rest.slice(maxMatch[0].length).trim();
+ }
+
+ const objective = rest;
+ if (!objective) {
+ displayErrorToast(t(I18nKey.GOAL$OBJECTIVE_REQUIRED)); // bare /goal — no objective to pursue
+ return;
+ }
+
+ const request: StartGoalRequest = { objective };
+ if (maxIterations && maxIterations >= 1) {
+ request.max_iterations = maxIterations;
+ }
+
+ startGoal(conversationId, request).catch((err: unknown) => {
+ const fallback = t(I18nKey.GOAL$START_FAILED);
+ const messageText =
+ err instanceof Error && err.message ? err.message : fallback;
+ displayErrorToast(messageText);
+ });
+ },
+ [conversationId, onSubmit, t],
+ );
+};
diff --git a/src/hooks/mutation/conversation-mutation-utils.ts b/src/hooks/mutation/conversation-mutation-utils.ts
index 647197f540..32d929650b 100644
--- a/src/hooks/mutation/conversation-mutation-utils.ts
+++ b/src/hooks/mutation/conversation-mutation-utils.ts
@@ -1,5 +1,6 @@
import { QueryClient } from "@tanstack/react-query";
import { ConversationClient } from "@openhands/typescript-client/clients";
+import type { StartGoalRequest } from "@openhands/typescript-client";
import { getActiveBackend } from "#/api/backend-registry/active-store";
import { pauseCloudSandbox } from "#/api/cloud/conversation-service.api";
import { getAgentServerClientOptions } from "#/api/agent-server-client-options";
@@ -73,6 +74,46 @@ export const askAgent = async (
).askAgent(conversationId, question);
};
+/**
+ * Start a `/goal` loop on a V1 conversation. The agent server drives the agent
+ * toward the objective, judging completion after each run until it is done or
+ * `max_iterations` is reached, streaming progress as goal
+ * ConversationStateUpdateEvents over the conversation's event stream.
+ */
+export const startGoal = async (
+ conversationId: string,
+ request: StartGoalRequest,
+): Promise<void> => {
+ const { conversationUrl, sessionApiKey } =
+ await fetchConversationData(conversationId);
+ await new ConversationClient(
+ getAgentServerClientOptions({ conversationUrl, sessionApiKey }),
+ ).startGoal(conversationId, request);
+};
+
+/**
+ * Stop the active `/goal` loop. The backend only cancels the background loop
+ * (recording an `interrupted` status so {@link resumeGoal} can continue it) and
+ * deliberately leaves the in-flight agent turn running, so callers should also
+ * interrupt the conversation (e.g. `pauseConversation`) to actually halt it.
+ */
+export const stopGoal = async (conversationId: string): Promise<void> => {
+ const { conversationUrl, sessionApiKey } =
+ await fetchConversationData(conversationId);
+ await new ConversationClient(
+ getAgentServerClientOptions({ conversationUrl, sessionApiKey }),
+ ).stopGoal(conversationId);
+};
+
+/** Resume the last interrupted `/goal` loop in this conversation. */
+export const resumeGoal = async (conversationId: string): Promise<void> => {
+ const { conversationUrl, sessionApiKey } =
+ await fetchConversationData(conversationId);
+ await new ConversationClient(
+ getAgentServerClientOptions({ conversationUrl, sessionApiKey }),
+ ).resumeGoal(conversationId);
+};
+
export const resumeConversation = async (conversationId: string) => {
const { conversationUrl, sessionApiKey } =
await fetchConversationData(conversationId);
diff --git a/src/hooks/query/use-conversation-history.ts b/src/hooks/query/use-conversation-history.ts
index a3e7228fcf..397529c4ba 100644
--- a/src/hooks/query/use-conversation-history.ts
+++ b/src/hooks/query/use-conversation-history.ts
@@ -70,7 +70,22 @@ export const useConversationHistory = (conversationId?: string) => {
nextPageId: page.next_page_id ?? null,
};
},
- staleTime: Infinity,
- gcTime: 30 * 60 * 1000, // 30 minutes — survive navigation away and back (AC5)
+ // Keep the cached page so returning to a conversation renders the
+ // last-known discussion instantly (no skeleton). But refetch the tail on
+ // mount so events produced while we were away — e.g. an active /goal loop
+ // that keeps emitting user + agent turns while we're on another
+ // conversation — arrive in one batched REST page instead of being
+ // back-filled one event at a time over the WebSocket `since` replay. The
+ // cached tail's newest timestamp never advances on its own, so without this
+ // refetch every return replays the entire post-first-load history over the
+ // socket (and it gets worse the longer the goal has been running).
+ //
+ // refetchOnWindowFocus is disabled because the WebSocket connection is
+ // gated on this query settling (see conversation-websocket-context.tsx); a
+ // focus-driven refetch would otherwise needlessly drop and reconnect it.
+ staleTime: 0,
+ gcTime: 30 * 60 * 1000, // 30 minutes — keep cached data to render instantly on return
+ refetchOnMount: "always",
+ refetchOnWindowFocus: false,
});
};
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 5f64150494..333d1c9403 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -9179,6 +9179,244 @@
"uk": "Очікування відповіді агента…",
"ca": "Esperant la resposta de l'agent…"
},
+ "GOAL$PREFIX": {
+ "en": "Goal:",
+ "ja": "ゴール:",
+ "zh-CN": "目标:",
+ "zh-TW": "目標:",
+ "ko-KR": "목표:",
+ "no": "Mål:",
+ "it": "Obiettivo:",
+ "pt": "Objetivo:",
+ "es": "Objetivo:",
+ "ar": "الهدف:",
+ "fr": "Objectif :",
+ "tr": "Hedef:",
+ "de": "Ziel:",
+ "uk": "Ціль:",
+ "ca": "Objectiu:"
+ },
+ "GOAL$ROUND": {
+ "en": "Round {{iteration}}/{{max}}",
+ "ja": "ラウンド {{iteration}}/{{max}}",
+ "zh-CN": "第 {{iteration}}/{{max}} 轮",
+ "zh-TW": "第 {{iteration}}/{{max}} 輪",
+ "ko-KR": "{{iteration}}/{{max}} 라운드",
+ "no": "Runde {{iteration}}/{{max}}",
+ "it": "Giro {{iteration}}/{{max}}",
+ "pt": "Rodada {{iteration}}/{{max}}",
+ "es": "Ronda {{iteration}}/{{max}}",
+ "ar": "الجولة {{iteration}}/{{max}}",
+ "fr": "Tour {{iteration}}/{{max}}",
+ "tr": "Tur {{iteration}}/{{max}}",
+ "de": "Runde {{iteration}}/{{max}}",
+ "uk": "Раунд {{iteration}}/{{max}}",
+ "ca": "Ronda {{iteration}}/{{max}}"
+ },
+ "GOAL$STATUS_RUNNING": {
+ "en": "running",
+ "ja": "実行中",
+ "zh-CN": "运行中",
+ "zh-TW": "執行中",
+ "ko-KR": "실행 중",
+ "no": "kjører",
+ "it": "in corso",
+ "pt": "em execução",
+ "es": "en ejecución",
+ "ar": "قيد التشغيل",
+ "fr": "en cours",
+ "tr": "çalışıyor",
+ "de": "läuft",
+ "uk": "виконується",
+ "ca": "en execució"
+ },
+ "GOAL$STATUS_COMPLETE": {
+ "en": "complete",
+ "ja": "完了",
+ "zh-CN": "已完成",
+ "zh-TW": "已完成",
+ "ko-KR": "완료",
+ "no": "fullført",
+ "it": "completato",
+ "pt": "concluído",
+ "es": "completado",
+ "ar": "مكتمل",
+ "fr": "terminé",
+ "tr": "tamamlandı",
+ "de": "abgeschlossen",
+ "uk": "завершено",
+ "ca": "completat"
+ },
+ "GOAL$STATUS_CAPPED": {
+ "en": "capped",
+ "ja": "上限到達",
+ "zh-CN": "已达上限",
+ "zh-TW": "已達上限",
+ "ko-KR": "한도 도달",
+ "no": "grense nådd",
+ "it": "limite raggiunto",
+ "pt": "limite atingido",
+ "es": "límite alcanzado",
+ "ar": "بلغ الحد",
+ "fr": "limite atteinte",
+ "tr": "sınıra ulaşıldı",
+ "de": "Limit erreicht",
+ "uk": "досягнуто ліміту",
+ "ca": "límit assolit"
+ },
+ "GOAL$STATUS_INTERRUPTED": {
+ "en": "interrupted",
+ "ja": "中断",
+ "zh-CN": "已中断",
+ "zh-TW": "已中斷",
+ "ko-KR": "중단됨",
+ "no": "avbrutt",
+ "it": "interrotto",
+ "pt": "interrompido",
+ "es": "interrumpido",
+ "ar": "تمت المقاطعة",
+ "fr": "interrompu",
+ "tr": "kesintiye uğradı",
+ "de": "unterbrochen",
+ "uk": "перервано",
+ "ca": "interromput"
+ },
+ "GOAL$SCORE": {
+ "en": "score {{score}}%",
+ "ja": "スコア {{score}}%",
+ "zh-CN": "得分 {{score}}%",
+ "zh-TW": "分數 {{score}}%",
+ "ko-KR": "점수 {{score}}%",
+ "no": "poengsum {{score}} %",
+ "it": "punteggio {{score}}%",
+ "pt": "pontuação {{score}}%",
+ "es": "puntuación {{score}}%",
+ "ar": "النتيجة {{score}}%",
+ "fr": "note {{score}} %",
+ "tr": "puan {{score}}%",
+ "de": "Bewertung {{score}} %",
+ "uk": "оцінка {{score}}%",
+ "ca": "puntuació {{score}}%"
+ },
+ "GOAL$MISSING": {
+ "en": "Missing: {{missing}}",
+ "ja": "未達成: {{missing}}",
+ "zh-CN": "尚缺:{{missing}}",
+ "zh-TW": "尚缺:{{missing}}",
+ "ko-KR": "남은 작업: {{missing}}",
+ "no": "Mangler: {{missing}}",
+ "it": "Mancante: {{missing}}",
+ "pt": "Faltando: {{missing}}",
+ "es": "Falta: {{missing}}",
+ "ar": "ناقص: {{missing}}",
+ "fr": "Manquant : {{missing}}",
+ "tr": "Eksik: {{missing}}",
+ "de": "Fehlt noch: {{missing}}",
+ "uk": "Бракує: {{missing}}",
+ "ca": "Falta: {{missing}}"
+ },
+ "GOAL$STOP": {
+ "en": "Stop",
+ "ja": "停止",
+ "zh-CN": "停止",
+ "zh-TW": "停止",
+ "ko-KR": "중지",
+ "no": "Stopp",
+ "it": "Ferma",
+ "pt": "Parar",
+ "es": "Detener",
+ "ar": "إيقاف",
+ "fr": "Arrêter",
+ "tr": "Durdur",
+ "de": "Stoppen",
+ "uk": "Зупинити",
+ "ca": "Atura"
+ },
+ "GOAL$STOP_FAILED": {
+ "en": "Failed to stop the goal loop",
+ "ja": "ゴールループの停止に失敗しました",
+ "zh-CN": "无法停止目标循环",
+ "zh-TW": "無法停止目標迴圈",
+ "ko-KR": "목표 루프를 중지하지 못했습니다",
+ "no": "Kunne ikke stoppe målsløyfen",
+ "it": "Impossibile fermare il ciclo dell'obiettivo",
+ "pt": "Falha ao parar o ciclo de objetivo",
+ "es": "No se pudo detener el ciclo de objetivo",
+ "ar": "فشل إيقاف حلقة الهدف",
+ "fr": "Échec de l'arrêt de la boucle d'objectif",
+ "tr": "Hedef döngüsü durdurulamadı",
+ "de": "Die Ziel-Schleife konnte nicht gestoppt werden",
+ "uk": "Не вдалося зупинити цикл цілі",
+ "ca": "No s'ha pogut aturar el cicle d'objectiu"
+ },
+ "GOAL$RESUME": {
+ "en": "Resume",
+ "ja": "再開",
+ "zh-CN": "继续",
+ "zh-TW": "繼續",
+ "ko-KR": "재개",
+ "no": "Fortsett",
+ "it": "Riprendi",
+ "pt": "Retomar",
+ "es": "Reanudar",
+ "ar": "استئناف",
+ "fr": "Reprendre",
+ "tr": "Devam et",
+ "de": "Fortsetzen",
+ "uk": "Відновити",
+ "ca": "Reprèn"
+ },
+ "GOAL$RESUME_FAILED": {
+ "en": "Failed to resume the goal loop",
+ "ja": "ゴールループの再開に失敗しました",
+ "zh-CN": "无法恢复目标循环",
+ "zh-TW": "無法恢復目標迴圈",
+ "ko-KR": "목표 루프를 재개하지 못했습니다",
+ "no": "Kunne ikke gjenoppta målsløyfen",
+ "it": "Impossibile riprendere il ciclo dell'obiettivo",
+ "pt": "Falha ao retomar o ciclo de objetivo",
+ "es": "No se pudo reanudar el ciclo de objetivo",
+ "ar": "فشل استئناف حلقة الهدف",
+ "fr": "Échec de la reprise de la boucle d'objectif",
+ "tr": "Hedef döngüsü devam ettirilemedi",
+ "de": "Die Ziel-Schleife konnte nicht fortgesetzt werden",
+ "uk": "Не вдалося відновити цикл цілі",
+ "ca": "No s'ha pogut reprendre el cicle d'objectiu"
+ },
+ "GOAL$OBJECTIVE_REQUIRED": {
+ "en": "Please provide an objective — e.g. /goal <objective>",
+ "ja": "目標を入力してください(例: /goal <objective>)",
+ "zh-CN": "请提供一个目标,例如 /goal <objective>",
+ "zh-TW": "請提供一個目標,例如 /goal <objective>",
+ "ko-KR": "목표를 입력하세요. 예: /goal <objective>",
+ "no": "Oppgi et mål, f.eks. /goal <objective>",
+ "it": "Inserisci un obiettivo, ad es. /goal <objective>",
+ "pt": "Forneça um objetivo, por exemplo /goal <objective>",
+ "es": "Proporciona un objetivo, por ejemplo /goal <objective>",
+ "ar": "يرجى تقديم هدف، مثل /goal <objective>",
+ "fr": "Veuillez fournir un objectif, par ex. /goal <objective>",
+ "tr": "Lütfen bir hedef girin, örn. /goal <objective>",
+ "de": "Bitte gib ein Ziel an, z. B. /goal <objective>",
+ "uk": "Вкажіть ціль, наприклад /goal <objective>",
+ "ca": "Proporciona un objectiu, p. ex. /goal <objective>"
+ },
+ "GOAL$START_FAILED": {
+ "en": "Failed to start the goal loop",
+ "ja": "ゴールループの開始に失敗しました",
+ "zh-CN": "无法启动目标循环",
+ "zh-TW": "無法啟動目標迴圈",
+ "ko-KR": "목표 루프를 시작하지 못했습니다",
+ "no": "Kunne ikke starte målsløyfen",
+ "it": "Impossibile avviare il ciclo dell'obiettivo",
+ "pt": "Falha ao iniciar o ciclo de objetivo",
+ "es": "No se pudo iniciar el ciclo de objetivo",
+ "ar": "فشل بدء حلقة الهدف",
+ "fr": "Échec du démarrage de la boucle d'objectif",
+ "tr": "Hedef döngüsü başlatılamadı",
+ "de": "Die Ziel-Schleife konnte nicht gestartet werden",
+ "uk": "Не вдалося запустити цикл цілі",
+ "ca": "No s'ha pogut iniciar el cicle d'objectiu"
+ },
"CHAT_INTERFACE$MESSAGE_SENDING": {
"en": "Sending...",
"ja": "送信中...",
diff --git a/src/stores/goal-store.ts b/src/stores/goal-store.ts
new file mode 100644
index 0000000000..2633182a3f
--- /dev/null
+++ b/src/stores/goal-store.ts
@@ -0,0 +1,33 @@
+import { create } from "zustand";
+import { devtools } from "zustand/middleware";
+import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event";
+
+interface GoalState {
+ /** Latest goal status per conversation, fed by goal state-update events. */
+ statusByConversation: Record<string, GoalStatus>;
+}
+
+interface GoalActions {
+ /** Replace the latest goal status for a conversation. */
+ setStatus: (conversationId: string, status: GoalStatus) => void;
+}
+
+type GoalStore = GoalState & GoalActions;
+
+const initialState: GoalState = { statusByConversation: {} };
+
+export const useGoalStore = create<GoalStore>()(
+ devtools(
+ (set) => ({
+ ...initialState,
+ setStatus: (conversationId, status) =>
+ set((s) => ({
+ statusByConversation: {
+ ...s.statusByConversation,
+ [conversationId]: status,
+ },
+ })),
+ }),
+ { name: "GoalStore" },
+ ),
+);
diff --git a/src/types/agent-server/core/events/conversation-state-event.ts b/src/types/agent-server/core/events/conversation-state-event.ts
index 4919b48051..e3c7454c02 100644
--- a/src/types/agent-server/core/events/conversation-state-event.ts
+++ b/src/types/agent-server/core/events/conversation-state-event.ts
@@ -61,6 +61,40 @@ export interface ConversationState {
// Add other conversation state fields here as needed
}
+/**
+ * The judge's verdict on whether a `/goal` objective is complete.
+ */
+export interface GoalVerdict {
+ /** Probability (0-1) that the full objective is provably done. */
+ score: number;
+ /** Whether the judge considers the objective complete. */
+ complete: boolean;
+ /** Concise description of what remains, or empty if complete. */
+ missing: string;
+}
+
+/**
+ * Live status of a `/goal` loop, streamed as the `value` of a
+ * ConversationStateUpdateEvent with `key: "goal"` at each lifecycle point
+ * (kickoff, each round, and the terminal/interrupted state).
+ */
+export interface GoalStatus {
+ /** Whether the goal loop is still running. */
+ active: boolean;
+ status: "running" | "complete" | "capped" | "interrupted";
+ /** Audit rounds completed so far (0 at kickoff). */
+ iteration: number;
+ /**
+ * Maximum audit rounds before the loop gives up. snake_case mirrors the
+ * agent-server `GoalStatus` payload (this event value is its `model_dump`);
+ * renaming it to camelCase would stop matching the streamed event JSON.
+ */
+ max_iterations: number;
+ objective: string;
+ /** Last judge verdict; null at kickoff and on an interrupted loop. */
+ verdict: GoalVerdict | null;
+}
+
interface ConversationStateUpdateEventBase extends BaseEvent {
/**
* Discriminator field for type guards
@@ -76,12 +110,12 @@ interface ConversationStateUpdateEventBase extends BaseEvent {
* Unique key for this state update event.
* Can be "full_state" for full state snapshots or field names for partial updates.
*/
- key: "full_state" | "execution_status" | "stats"; // Extend with other keys as needed
+ key: "full_state" | "execution_status" | "stats" | "goal"; // Extend with other keys as needed
/**
* Conversation state updates
*/
- value: ConversationState | ExecutionStatus | ConversationStats;
+ value: ConversationState | ExecutionStatus | ConversationStats | GoalStatus;
}
// Narrowed interfaces for full state update event
@@ -102,11 +136,18 @@ export interface ConversationStateUpdateEventStats extends ConversationStateUpda
value: ConversationStats;
}
+// Narrowed interface for goal status update event
+export interface ConversationStateUpdateEventGoal extends ConversationStateUpdateEventBase {
+ key: "goal";
+ value: GoalStatus;
+}
+
// Conversation state update event - contains conversation state updates
export type ConversationStateUpdateEvent =
| ConversationStateUpdateEventFullState
| ConversationStateUpdateEventAgentStatus
- | ConversationStateUpdateEventStats;
+ | ConversationStateUpdateEventStats
+ | ConversationStateUpdateEventGoal;
// Conversation error event - contains error information
export interface ConversationErrorEvent extends BaseEvent {
diff --git a/src/types/agent-server/type-guards.ts b/src/types/agent-server/type-guards.ts
index 5c5d91aba9..485ba2358f 100644
--- a/src/types/agent-server/type-guards.ts
+++ b/src/types/agent-server/type-guards.ts
@@ -20,6 +20,7 @@ import {
ConversationStateUpdateEventAgentStatus,
ConversationStateUpdateEventFullState,
ConversationStateUpdateEventStats,
+ ConversationStateUpdateEventGoal,
ConversationErrorEvent,
ServerErrorEvent,
} from "./core/events/conversation-state-event";
@@ -211,6 +212,10 @@ export const isStatsConversationStateUpdateEvent = (
event: ConversationStateUpdateEvent,
): event is ConversationStateUpdateEventStats => event.key === "stats";
+export const isGoalConversationStateUpdateEvent = (
+ event: ConversationStateUpdateEvent,
+): event is ConversationStateUpdateEventGoal => event.key === "goal";
+
/**
* Type guard function to check if an event is a conversation error event
*/
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index d2a37bde27..340d34c1b8 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -41,6 +41,9 @@ export const BTW_COMMAND = "/btw";
/** The /model slash command — lists or switches the conversation's LLM profile. */
export const MODEL_COMMAND = "/model";
+/** The /goal slash command — drives the agent toward an objective, judging completion each round. */
+export const GOAL_COMMAND = "/goal";
+
/** Built-in slash commands surfaced in the menu for V1 conversations. */
export const BUILT_IN_COMMANDS: SlashCommandItem[] = [
{
@@ -71,6 +74,16 @@ export const BUILT_IN_COMMANDS: SlashCommandItem[] = [
},
command: MODEL_COMMAND,
},
+ {
+ skill: {
+ name: "goal",
+ type: "agentskills",
+ content:
+ "Drive the agent toward an objective until a judge says it's done — /goal <objective> or /goal --max <n> <objective>",
+ triggers: [GOAL_COMMAND],
+ },
+ command: GOAL_COMMAND,
+ },
];
// Skill content metadata prefixes