feat(agent): long-running task loop with LLM-planned proposals#2264
Closed
robbie-c wants to merge 2 commits into
Closed
feat(agent): long-running task loop with LLM-planned proposals#2264robbie-c wants to merge 2 commits into
robbie-c wants to merge 2 commits into
Conversation
Adds an auto-continuing turn loop that the agent enters when the user approves a proposal block. While active, the harness pushes a continuation user message after each end_turn until the agent emits a configured marker, hits a max-iteration cap, or the user steers/stops. The /long-running-task slash command sends a brief planning prompt with hidden context — the agent explores the codebase, asks clarifying questions via AskUserQuestion when intent is ambiguous, then emits the config as a <long-running-task-config> JSON block. The renderer parses that block, shows an inline confirmation card (editable goal/criterion/marker/max), and on Start sets the server-side state via a new tRPC mutation + sends the kickoff prompt. While a task is active, a pill above the prompt input shows iterations N/M + goal + a Stop button. Mid-loop user messages pause auto-continuation for that turn so the user can steer. Generated-By: PostHog Code Task-Id: c1333c34-d768-47e2-9dda-d2e456ab701a
Refactors the long-running task helpers to be adapter-agnostic and adds the same loop primitive to the codex adapter. - decideLongRunningTaskStep now returns the continuation text instead of pushing it; caller routes it through the right turn mechanism (session.input push for claude, new PromptRequest for codex) - LRT system-prompt instructions extracted to a shared module that both adapters append to their system prompt - codex runPrompt wraps codexConnection.prompt() in a while loop — each iteration is a fresh ACP turn, no broadcast on continuations so the user only sees the original prompt in chat - codex-client forwards every session notification to the session's notificationHistory so getLatestAssistantText finds the agent's text for marker + proposal detection - codex extMethod handles START / STOP and emits the same update notifications the renderer already listens for - codex spawn instructions get LRT instructions appended, mirroring the Claude APPENDED_INSTRUCTIONS path Generated-By: PostHog Code Task-Id: c1333c34-d768-47e2-9dda-d2e456ab701a
9246890 to
fa85fa1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an auto-continuing turn loop the agent can enter for tasks with an objective, measurable success criterion (test pass count, bundle size, error count, etc.). Inspired by Anthropic's Ralph Wiggum plugin but redesigned around the desktop agent framework instead of a bash loop.
How it works
/long-running-task <description>(or the agent self-initiates)._metacontext. The agent explores first — reads relevant files, runs measurement commands, asks clarifying questions viaAskUserQuestiononly when intent is genuinely ambiguous.<long-running-task-config>{...}</long-running-task-config>JSON block (goal, successCriterion, marker, maxIterations, approach).end_turnand shows an inline confirmation card above the prompt input — editable fields, Start / Edit / Cancel.end_turnwhile the task is active, the loop inclaude-agent.tspushes a continuation user message intosession.inputand keeps the while-loop alive instead of returning. The agent exits when:<TASK_COMPLETE>) in its assistant textA pill above the prompt input shows iteration count + goal + Stop button while a task is active.
Files of note
packages/agent/src/adapters/claude/long-running-task/utils.ts— schemas, continuation builder, proposal parser, broadcast helperspackages/agent/src/adapters/claude/claude-agent.ts— loop hook in theresult.subtype === "success"branch + newSTART_LONG_RUNNING_TASK/STOP_LONG_RUNNING_TASKextMethodspackages/agent/src/adapters/claude/session/instructions.ts— appended system prompt teaching the proposal workflowapps/code/src/renderer/components/long-running-task/— pill + proposal cardapps/code/src/renderer/stores/longRunningTaskStore.ts— Zustand store keyed bytaskRunIdKnown limitations
extMethoddoesn't work over the cloud path.Test plan
/long-running-taskwith an iterative task (e.g. fix N failing tests). Agent explores, asks if needed, emits proposal block, card renders.0/20, loop kicks in./long-running-taskon a cloud task → toast says not supported.Created with PostHog Code