Skip to content

fix: keep every answer when a model task asks again - #191

Open
Bortlesboat wants to merge 1 commit into
CopilotKit:mainfrom
Bortlesboat:fix/keep-task-answers
Open

Bortlesboat wants to merge 1 commit into
CopilotKit:mainfrom
Bortlesboat:fix/keep-task-answers

Conversation

@Bortlesboat

Copy link
Copy Markdown

What changed

A delegated model task that asks the user more than one question forgets the earlier replies.

Each model run starts from a single user message built from the task prompt plus state.answer. AgentService.answer overwrote state.answer, and the question itself is cleared when the task is requeued. So when a task asked "Which date should I use?" (answer "Friday") and then "What time works?" (answer "3pm"), the third run was sent only:

Plan a sample walk
Additional answer: 3pm

"Friday" was gone from the request entirely, including priorState in the instructions, and the model had no way to know what "3pm" was answering.

answer now appends { question, answer } to state.answers, and the model run sends every reply after the prompt as You asked: ... / Answer: .... A task saved with the old single answer field is still read, so tasks already waiting on input keep their reply.

Verification

  • Added a model task keeps every earlier answer when it asks again to tests/model-outcome.test.ts. It drives two ask_user rounds and a finish_task through the model fixture and checks that the third request contains both questions and both replies. It fails on main with the message shown above and passes with this change.
  • pnpm lint, pnpm typecheck, pnpm --dir apps/worker typecheck and pnpm build:server pass.
  • pnpm test: 479 pass. On Windows, worker recovery preserves downloads when metadata cannot be inspected fails on main too (symlink EPERM without Developer Mode), and the telemetry probe can hit its 15s timeout under the full suite (Tests: telemetry probes can exceed their 15s execFile timeout on Windows (cold tsx transpile + AV scanning) #176); it passes when run alone.

Each model run starts with only the task prompt, so the reply to an
earlier ask_user question has to come from saved state. Answering
overwrote state.answer, so a task that asked two questions lost the
first reply and the model never saw which question a reply answered.

Keep the replies as a list with their questions and send all of them.
Tasks saved with a single answer still read it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant