A script pipes multica agent tasks <agent-id> --output json 2>/dev/null into jq length and gets 200. That number could be the whole history or only its newest page. The cursor for the next page went to stderr, and 2>/dev/null threw it away. Stdout was, in the reporter's words, "a bare JSON array, the same shape as a complete history."
That's from a public bug report against the Multica CLI, and it's a good one. It names the command, the symptom and the expected behaviour, and it asks for the fix behind a flag so existing scripts keep working. Five answers are still open, though, and each one changes what an agent may touch or what evidence counts as done. Checking them changed this task three times before anyone wrote code.
In my article on planning, a full groom, where an agent reads the code and docs and commits a plan before writing any code, didn't pay for itself on every small ticket. This is the lighter pass: check only the assumptions a task rests on.
| Question | Fills in the handoff | Can end in |
|---|---|---|
| 1. Is the premise true in the code? | PRESENT STATE | stop |
| 2. What observable outcome do we want? | WORK, ACCEPT | dispatch |
| 3. Who can authorize the change? | KEEP | ask |
| 4. Has someone already started it? | PRESENT STATE, WORK | stop, or dispatch a review |
| 5. What would make acceptance fail? | ACCEPT, RECEIPT | dispatch the fixture first |
Each question can end in one of three moves: stop when the task is wrong or already done, ask when only the owner can answer, and dispatch when the agent has what it needs. The sections below answer the five questions for this one ticket, and the last section assembles the handoff they produce.
1. Is the Premise True in the Code?
Start with what the request actually says. A paraphrase tends to make a ticket sound worse than it is. Issue #8975, opened on September 30, asks for this:
- In JSON mode, the next-page cursor should be available on stdout.
- Put it behind a flag, "so the bare array stays the default", and emit
{"tasks": [...], "next_cursor": "<cursor or null>"}. - Don't make
--allthe default, because "for large histories it brings back the unbounded download" a previous change removed. - Don't rebuild the cursor from the last row: rows show
created_atto the second, the cursor carries microseconds.
That's four claims to check, and a ticket is a description of code at the moment someone looked. So the first job is to find each claim in source at a pinned revision. I'd do this before writing a word of the handoff, because every later answer leans on it. An agent handed an unchecked premise will either fix the bug as described or "reproduce" it with whatever it finds, and neither tells you where the defect actually lives.
At e1fe10d, runAgentTasks in server/cmd/multica/cmd_agent.go reads the X-Agent-Tasks-Next-Cursor response header. When it's non-empty, the CLI writes "More runs available; use --before ..." through cmd.ErrOrStderr(). Then it returns cli.PrintJSON(os.Stdout, tasks). One request, one page, the continuation on the other stream. The report is right about where the signal goes.
The server side matters more for scope. The handler defaults and caps the limit at 200, asks the database for limit + 1 rows, trims the extra one and sets the header when it existed. A comment says it plainly: "An absent header means this is the last page." The server already knows whether more history exists. It says so in a header the JSON consumer never sees.
That rules out two tempting tasks. One is "add pagination to the backend", which already exists. The other is "fetch everything", which would undo the 200-row cap the request itself defends. The cursor is also scoped to one agent's tasks as the caller is allowed to see them, so "complete" in this handoff means complete for that query, not every run on the server.
Decision: no stop, because the premise holds. Checking it narrowed the fix to one place, how the CLI writes JSON, and the handoff names that place instead of a vague "pagination is broken".
2. What Observable Outcome Do We Want?
"Expose the cursor on stdout" describes an implementation. I'd rather name the outcome: what a JSON consumer can do afterwards. It needs three things from stdout alone: the page of runs, the exact token to ask for the next page, and an unambiguous signal that there is no next page.
Think about who that consumer is. The reporter's own command ends in 2>/dev/null, so the one line that says "there's more" is gone before jq sees anything. A signal that only exists on stderr never reaches a consumer built like that, whether it's a script or an agent reading the command's output.
The request already sketches that envelope, and the open pull request #8986 builds it behind a --with-cursor flag. The shapes a consumer should be able to rely on look like this:
# more runs exist: the token is the header value, unchanged
{"tasks": [ ...200 runs... ], "next_cursor": "2026-09-30T04:09:26.643721Z|<task-id>"}
# last page
{"tasks": [ ...1 run... ], "next_cursor": null}
# no runs at all
{"tasks": [], "next_cursor": null}Two words in that contract do most of the work. "Unchanged" means the CLI copies the header byte for byte, and the consumer passes it back without parsing it. "Present" means next_cursor is always a key, null at the end, never missing. A test that reads a missing key and a null the same way can't check that promise, and section 4 finds exactly that gap in the open pull request.
The envelope hands the caller what it needs to fetch the remaining pages. Fetching them stays the caller's job, and the 200-row cap stays where it is. A fair trade, I think: the cap protects the server, the token protects the caller.
Decision: dispatch against the consumer-visible contract above. An agent that returns "all runs in one response" has missed it. I'd rather an agent come back with "the envelope works, here are the three shapes" than with a clever loop that hides the pages.
3. Who Can Authorize the Change?
Here the original request deserves credit. It asks for the envelope behind a flag, and it explains why: scripts written against older versions parse a bare array. The reporter drew the compatibility line before anyone asked.
The temptation runs the other way. Every script that silently gets 200 rows today would be fixed tomorrow if the envelope became the default. It's also a breaking change for every one of those scripts, the ones that parse .[] and would now get an object. That decision belongs to whoever owns the CLI's output contract. An agent can't make it, and neither can the person writing the ticket.
So the handoff keeps four things fixed, in writing:
- The default JSON output stays a bare array.
- The table output follows its existing path.
- The stderr hint still prints, so humans keep their prompt.
- The 200-row cap stays: at most 200 runs per request.
Writing these down turns compatibility from an assumption the agent might share into a rule it can't break without someone noticing. Making the envelope the default is a one-line diff in the same function, and from inside that file it looks like an improvement. A written line is what tells the agent this improvement belongs to someone else.
It also limits what the agent may do: no merge, no deployment, no message to the maintainers. Those are the owner's calls, and I'd keep them out of the agent's reach even when the change looks trivial.
Decision: ask the owner only if the work needs to change one of those four lines, such as making the envelope the default. Otherwise there's nothing to ask.
4. Has Someone Already Started It?
Before sending this task, I'd check whether someone has already implemented it. A ticket from September describes code from September, and the agent will work on code from the day it starts. In August, a worker on my own board declined a task because the function it was asked to change had been deleted weeks earlier. It left a blocker naming the change that superseded it, touched nothing, and the live part of the problem became a new, narrower task.
Here, someone has, on the same day the issue was filed. Pull request #8986 adds the --with-cursor flag. With it, the JSON branch builds {"tasks": tasks, "next_cursor": nil} and copies a non-empty header into the cursor. Default output, the table path and the stderr hint stay as they were. As of November 22 it's open and unmerged, last updated on November 8. Dispatching "implement the envelope" now would commission a duplicate.
I'd give the agent the existing patch and the target checkout together, and have it record that checkout's revision. The useful question is which acceptance checks still fail on it.
So I'd make the first job a review of the existing pull request against that target. If every acceptance check already passes there, because the change merged in the meantime or the patch holds up as written, the agent returns its receipt and "nothing to build". That turns the decision into a stop, and the task closes without a diff.
Adaptation needs a verified gap: an ACCEPT line that fails on that checkout, with the command and its output in the receipt. "I'd structure this differently" isn't a gap. One candidate is already visible in the source.
The pull request's tests decode next_cursor into a fresh Go *string and check for nil, and a missing key and an explicit null both leave that field nil. The empty-page test checks the slice length, which can't tell [] from a missing or null tasks. The implementation does write the key, but the tests wouldn't catch a regression that dropped it. Adding a raw check closes that gap: key present, next_cursor a string or null, tasks an array. Rewriting the envelope doesn't follow from it unless a check on the envelope itself fails.
Decision: dispatch a review of the existing work first. A new implementation waits until the review finds a gap.
5. What Would Make Acceptance Fail?
An acceptance check earns its place only if a wrong answer fails it. For this ticket, the wrong answer that matters is a page-by-page walk that looks finished and has quietly skipped a run. Here's that failure in a controlled offline model of the server's pagination, with fixed histories. The same check still has to pass against the real CLI before anyone accepts the work.
History A has 200 runs. History B has the same 200 plus one more, ID ...201, created at 04:09:26.400000 in the same second as the last run on the first page, which sits at .500000. Serialized as bare arrays, the two first pages are byte-identical, down to the same SHA-256. No check on that output, however careful, can say which history it came from.
The continuation is where they split.
The negative control
A cursor rebuilt from the displayed row skips one run and still reaches a clean end
Both walks end on a null cursor. Only a list of known IDs shows the run the rebuilt token skipped.
Both walks start from the same first page: 200 runs, IDs 001 to 200. The last row, ID 200, displays 04:09:26Z, while its token stores 04:09:26.500000. The one remaining run, ID 201, sits at 04:09:26.400000 in the same second. Passing the token unchanged asks for runs older than .500000: the next page holds ID 201, the cursor is null, and the walk reaches 201 of 201 IDs. Rebuilding the token from the displayed row moves the boundary to .000000: ID 201 is newer than that, so the next page is empty, the cursor is null, and the walk reaches 200 of 201 IDs, with ID 201 missing. A strip of all 201 runs under each walk shows the one missing run at its true size.
Controlled offline model of the server's pagination contract, one fixed history of 201 runs, page limit 200, ordered by (created_at, id) descending. Not captured CLI output: the acceptance check runs the same walk against the real CLI.
IDs shortened to their last three digits. The strips are drawn to scale: each run is 1/201 of the width.
Data behind this figure
| Continuation | Token | Next page | Terminal cursor | IDs reached | Missing |
|---|---|---|---|---|---|
| Pass the token unchanged | 2026-09-30T04:09:26.500000Z|...200 | ...201 | null | 201 of 201 | none |
| Rebuild it from the displayed row | 2026-09-30T04:09:26Z|...200 | empty | null | 200 of 201 | ...201 |
Both continuations start from the same first page of 200 runs (IDs ...001 to ...200). Zero unexpected IDs and zero duplicates in both walks.
The broken walk passes every surface check: valid JSON, exit 0, a terminal null, no duplicates. The cause is mundane. The displayed row has a timestamp and an ID, the cursor is a timestamp and an ID joined by a pipe, and gluing the displayed pair together drops six digits of precision. The request warned about it in one sentence. An acceptance check that can't catch it leaves that sentence as advice.
A terminal null proves the walk ended. It doesn't prove the walk was complete.
So acceptance needs an oracle that knows the answer before the agent runs. I'd load a fixed history with known IDs, walk it through the real CLI, then reconcile: zero missing, zero unexpected, zero duplicates. The rounded-cursor walk is the negative control. It must fail that same assertion, or the assertion is decoration. That's the question I'd put to any green check, as in when to trust agent tests: what wrong answer would it reject? (In Maestro I page session history by each event's integer sequence, so precision can't bite, and a client there still reconciles what it got.)
That oracle has a prerequisite: an isolated CLI and API environment, records with controlled timestamps, and access to the raw response, header included. Setting that up and keeping it working is the real cost of this check. It proves completeness for a fixed history. Retention, permission changes and a history that changes mid-walk are separate questions.
Decision: dispatch the review once the fixture exists, against the real CLI and API at the chosen revision. If it doesn't exist yet, the first dispatch builds the fixture and checker, with a receipt showing the exact token succeeding and the rebuilt one failing.
The Filled Agent Task Checklist
Here is the handoff the five answers produce. It's the one I'd send, and every line comes from an answer above.
PRESENT STATE
CLI (read at main 4ceffd5 and af0aa65, identical to e1fe10d): JSON stdout
is a bare array, cursor only in the stderr hint.
Server (read at e1fe10d): cap 200, limit+1 probe, X-Agent-Tasks-Next-Cursor.
Open PR #8986 head 42526d0 adds --with-cursor.
Before starting: record the target revision you check out, reread
#8975 and #8986, and re-verify the two facts above on that target.
WORK
Review #8986 against the target. Adapt only where a check below fails.
Copy the header token into next_cursor unchanged.
If the target already passes every check, report that and stop.
KEEP
Default bare-array JSON, table output, stderr hint, 200 cap.
Escalate any default-shape change to the CLI owner. No merge,
deployment or maintainer contact.
ACCEPT (real CLI against a fixed known history)
FIXTURE: 201 runs, stable unique IDs, ordered (created_at, id) desc.
Page one's last row at 2026-09-30T04:09:26.500000Z, the remaining
row at 04:09:26.400000Z. History unchanged during traversal.
Same shape as the appendix fixture.
201 runs: first page has 200 and a string cursor equal to the header.
Remaining page: 1 run, next_cursor present and null.
Exactly 200 runs: one page, next_cursor present and null.
No runs: {"tasks": [], "next_cursor": null}, keys and types checked raw.
Exact-token walk: all 201 IDs, zero missing, unexpected or duplicates.
Control token: displayed whole-second created_at + "|" + last-row ID.
Control walk reaches a null cursor and misses the remaining ID, so it
fails that same reconciliation.
Legacy default, table and stderr output unchanged.
RECEIPT
Revision, commands, exit codes, expected vs received IDs, terminal page.The FIXTURE line is the one I'd never let a copy drop. Without the .500000 and .400000 pair in the same second, both walks reconcile and the negative control proves nothing.
RECEIPT is what I'd read first when the agent reports back. A claim of "all checks pass" tells me little. A revision hash, the exact commands, exit codes and the list of expected versus received IDs tell me which checks ran, on what, and whether the negative control actually failed. If the receipt is missing a line, the work isn't accepted, however good the diff looks.
To reuse the five blocks on your own ticket, fill them from two sources. WORK and KEEP mostly come from the ticket and its owner: what was asked, and the constraints it already states, like this request's flag that keeps the bare array as the default. PRESENT STATE, the existing-work line and the ACCEPT fixture need fresh evidence, read on the day you dispatch: the code at a named revision, the state of related pull requests, and a history the checker can walk. RECEIPT stays the same shape for every task.
A block you can't fill tells you which decision you're facing. An empty PRESENT STATE means stop until someone reads the code. A KEEP line only the owner can change means ask. An ACCEPT block with no fixture behind it means the first dispatch builds the fixture, and the fix waits its turn.
I think of the three decisions as triggers rather than steps: each fires on a condition. Stop fires if the target already passes every check, or if the premise fails on that revision. Ask fires only if someone wants the work to cross the KEEP block. Dispatch fires once the target revision is chosen, the scope stays inside KEEP and the ACCEPT block can run.
Use the Check Where an Answer Changes the Work
Not every task needs this. A clear, low-risk change with fresh evidence and a checker that already exists can go out on the handoff it has. My planning article routes rich tickets straight to execution, and this check doesn't undo that.
Use the five questions where an answer is missing, or where it would change scope, authority or acceptance. Here, every answer did. The premise narrowed the fix to one place, the outcome became a contract, authority stayed with the owner, an open pull request turned implementation into review, and the acceptance check had to reject a walk that skipped one run.
Take one task waiting in your queue. Write the one answer that would change its scope or its acceptance before you dispatch it.
Methodology and full results
What the check is. A controlled offline model of the server's pagination contract: about 70 lines of Python, with fixed histories. It reads no Multica code at runtime and calls no network API. The first-page bytes below are the model's serialization, not captured CLI output. The model sorts (created_at, id) tuples descending, returns limit rows, emits a cursor only when a limit + 1th row exists, and filters the next page with an exclusive tuple boundary. The cursor carries microseconds. Displayed rows carry created_at to the second, matching the RFC3339 formatter the server uses.
Fixtures. History A: 200 runs, IDs 00000000-...-000000000001 to ...000200, one second apart, the last at 2026-09-30T04:09:26.500000Z. History B: A plus ...000201 at 2026-09-30T04:09:26.400000Z.
Command. Save the script below as pagination_receipt.py and run:
python3 -I pagination_receipt.py --output ./receiptInterpreter: Python 3.15.2. Exit status 0, all assertions passed. It writes both bare arrays, both first-page envelopes, the exact and rounded continuation pages and receipt.json.
| Observation | Result |
|---|---|
| Bare first pages, A and B | Byte-identical, 200 rows each, SHA-256 53247d5f1ee5de29fcf707b80922981f0b50db68a71d2a6e7ee9ea9103de03a4 |
| A cursor | null |
| B cursor | 2026-09-30T04:09:26.500000Z|00000000-...-000000000200 |
| B, exact cursor walk | 201 received, 0 missing, 0 unexpected, 0 duplicates, next page cursor null |
B, rounded cursor 2026-09-30T04:09:26Z|...000200 |
Next page empty, cursor null. 200 received, ...000201 missing, 0 unexpected, 0 duplicates |
| Empty history | {"tasks":[],"next_cursor":null} |
Abbreviated receipt (UUIDs shortened as 00000000-...-000000000201; the script writes them in full):
{
"kind": "controlled offline model; not upstream binary or integration test",
"python": "3.15.2",
"page_limit": 200,
"bare_pages_byte_identical": true,
"bare_page_sha256": "53247d5f1ee5de29fcf707b80922981f0b50db68a71d2a6e7ee9ea9103de03a4",
"a_expected": 200,
"a_cursor": null,
"a_reconciliation": {"received": 200, "missing": [], "unexpected": [], "duplicates": 0},
"b_expected": 201,
"b_cursor": "2026-09-30T04:09:26.500000Z|00000000-...-000000000200",
"opaque_cursor_reconciliation": {"received": 201, "missing": [], "unexpected": [], "duplicates": 0},
"rounded_cursor": "2026-09-30T04:09:26Z|00000000-...-000000000200",
"rounded_cursor_reconciliation": {
"received": 200,
"missing": ["00000000-...-000000000201"],
"unexpected": [],
"duplicates": 0
},
"rounded_cursor_terminal": null,
"empty": {"tasks": [], "next_cursor": null}
}The script:
"""Offline pagination contract check; never invokes Multica or a network API."""
import argparse
import hashlib
import json
import platform
from datetime import datetime, timedelta, timezone
from pathlib import Path
def encode(value):
return (json.dumps(value, separators=(",", ":")) + "\n").encode()
def page(history, limit, before=None):
rows = sorted(history, reverse=True)
if before is not None:
stamp, ident = before.split("|")
boundary = (datetime.fromisoformat(stamp), ident)
rows = [row for row in rows if row < boundary]
selected = rows[:limit]
cursor = None
if len(rows) > limit:
stamp, ident = selected[-1]
cursor = stamp.isoformat(timespec="microseconds").replace("+00:00", "Z") + "|" + ident
return {
"tasks": [{"id": ident, "created_at": stamp.isoformat(timespec="seconds").replace("+00:00", "Z")} for stamp, ident in selected],
"next_cursor": cursor,
}
def reconcile(expected, received):
want = {ident for _, ident in expected}
got = [row["id"] for row in received]
return {"received": len(got), "missing": sorted(want - set(got)),
"unexpected": sorted(set(got) - want), "duplicates": len(got) - len(set(got))}
def run(limit, output):
boundary = datetime(2026, 9, 30, 4, 9, 26, 500000, tzinfo=timezone.utc)
history_a = [(boundary + timedelta(seconds=limit - i), f"00000000-0000-0000-0000-{i:012d}") for i in range(1, limit + 1)]
history_b = history_a + [(boundary - timedelta(microseconds=100000), f"00000000-0000-0000-0000-{limit + 1:012d}")]
a, b = page(history_a, limit), page(history_b, limit)
bare_a, bare_b = encode(a["tasks"]), encode(b["tasks"])
assert bare_a == bare_b
assert a["next_cursor"] is None and b["next_cursor"] is not None
last = b["tasks"][-1]
rounded = last["created_at"] + "|" + last["id"]
good_next, bad_next = page(history_b, limit, b["next_cursor"]), page(history_b, limit, rounded)
correct = reconcile(history_b, b["tasks"] + good_next["tasks"])
negative = reconcile(history_b, b["tasks"] + bad_next["tasks"])
assert correct["received"] == limit + 1 and not correct["missing"] and correct["duplicates"] == 0
assert len(negative["missing"]) == 1 and bad_next["next_cursor"] is None
assert page([], limit) == {"tasks": [], "next_cursor": None}
assert good_next["next_cursor"] is None
receipt = {
"kind": "controlled offline model; not upstream binary or integration test",
"python": platform.python_version(), "page_limit": limit,
"bare_pages_byte_identical": True, "bare_page_sha256": hashlib.sha256(bare_a).hexdigest(),
"a_expected": limit, "a_cursor": a["next_cursor"], "a_reconciliation": reconcile(history_a, a["tasks"]),
"b_expected": limit + 1, "b_cursor": b["next_cursor"],
"opaque_cursor_reconciliation": correct, "rounded_cursor": rounded,
"rounded_cursor_reconciliation": negative,
"rounded_cursor_terminal": bad_next["next_cursor"], "empty": page([], limit),
}
output.mkdir(parents=True, exist_ok=True)
for name, value in {"a-bare.json": a["tasks"], "b-bare.json": b["tasks"], "a-envelope.json": a,
"b-envelope.json": b, "b-next.json": good_next, "rounded-next.json": bad_next,
"receipt.json": receipt}.items():
(output / name).write_bytes(encode(value))
print(json.dumps(receipt, indent=2))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--limit", type=int, default=200)
parser.add_argument("--output", type=Path, required=True)
args = parser.parse_args()
if args.limit < 1:
parser.error("--limit must be positive")
run(args.limit, args.output)Sources read for the premise and pins (all public, read November 22, 2026): issue #8975, pull request #8986, the CLI's runAgentTasks, the handler, the ordering query, the timestamp formatter, and the pull request's implementation and tests. Full revisions: CLI 4ceffd536603c67620c7460f6c412dcbf092299e and af0aa65b393f6e44d1e2121e73965933c8ece291 (both byte-identical in cmd_agent.go to e1fe10d6694848e35dd1aa00e08cd11d93e545ac), pull request head 42526d0b1dff873e563c8c87f1c72f5cfacb6240.
