Skip to content

An agent can re-queue its own task from inside the run (request-triage in every starter) #24

Open

Description

@ahmad-ajmal

Summary

An agent working on a triage task can queue another triage of the same record from inside its own run, and the bridge then hands that new task to the agent too. Nothing stops each run from queuing the next.

Found while testing #22 end to end with a real agent (Pi, through agent-app <dir> bridge start) on the pocketbase-react starter. It happened in both real runs. The cause is in the starter design every blueprint shares, not in the PocketBase adapter.

What happens:

  1. The person clicks "Ask an agent"; request-triage queues task A and stores its id in the record's agentTask.
  2. The bridge claims A and starts the agent.
  3. To understand the task, the agent opens the record's screen (a2app . planning tasks <id>). That screen lists request-triage as available, because its only condition is status ne done.
  4. The agent runs it. That queues task B for the same record (its payload names A as previous, so it is a new occurrence and is not deduplicated), and points agentTask at B.
  5. A completes. The bridge picks up B and starts the agent again, which can repeat step 4.

Evidence (PocketBase request log; user agent node is the a2app CLI the agent drives, not the browser):

10:41:55 POST /api/_a2app/tasks/tsk_7daa9505e25f7995/claim 200      ← bridge claims A
10:42:07 GET  /api/collections/tasks/records/6fq5hdnxkn14gk8 200    ← agent reads the record
10:42:10 POST /api/ops/request-triage 200                           ← agent queues B
10:43:12 POST /api/_a2app/tasks/tsk_7daa9505e25f7995/complete 200   ← A done
10:43:19 POST /api/_a2app/tasks/tsk_7885361b92a50133/claim 200      ← bridge claims B

The agent noticed, in its own result for A: "an extra triage request was inadvertently queued while inspecting the task, so the task record now references tsk_7885361b92a50133 as its agentTask."

Effects:

  • Repeated runs: each run can queue another, so agent time and cost keep growing, and the record is edited again on every pass. In testing, the bridge was stopped after A finished.
  • The answer goes off screen: the record now points at B, so the View follows B, and A's result is no longer shown on the row.

Affected: every blueprint's starter. request-triage in react-node (a2app.schema.mjs), go-react (schema.go), rust-react (src/schema.rs), rails-vue (lib/a2app_schema.rb), python-fastapi (schema.py) and pocketbase-react (pb/pb_hooks/operations.js) is available on any task that is not done, and none checks for a run already in progress.

Proposal

  1. Starter guard (every blueprint):
    • Rule: request-triage refuses while the record's current agent task (agentTask) is unfinished (submitted, working or input-required). It answers 409 with a code such as already_queued that names the open task.
    • Why it works: the agent's own run is unfinished at the moment it tries to re-queue, so this blocks exactly this case. It also covers a person asking from a second tab. Asking again after a run finishes (completed, failed or canceled) keeps working as today.
    • Reading the task: where a runner cannot read a task's state, the blueprint gives it a way. The PocketBase runner toolbox, for one, has no task read today.
  2. Bridge prompt (framework): the prompt in framework/cli/src/lib/bridge.ts tells the agent not to run operations that queue agent work for the record it was handed. This is a backstop for app-specific operations that do not have the guard; on its own it is not enough, since agents do not always follow instructions.
  3. Docs: the creator skill's app→agent section and each reference/blueprint.md say that an operation which queues agent work must refuse while that record already has open agent work.

Acceptance

  • Guard: in every starter, request-triage on a record whose agentTask is unfinished answers 409 and queues nothing. Once that task is finished, it queues new work.
  • Real run: a harness run through agent-app <dir> bridge start on a starter ends with exactly one task for the record, even when the agent calls request-triage during its run.
  • Prompt: agent-app <dir> bridge start --dry-run shows the new instruction.
  • Tests: each starter's own tests (or gate self-test, where a stack has no test suite) cover the refusal and the re-ask after completion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions