fix.sh: the emit_observe fallback reads its own token before the agent CLI renders it, so it always reports not_found

Open
#1,386 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
bash, shell

Research direction

Start in fix.sh and scripts/lib/token-locate.sh (agmsg_token_locate_self): the emit_observe path prints a token then immediately scans panes in the same invocation, which misses output the agent CLI only renders after the tool returns. Split print vs observe across two steps after the seat’s completion signal, keep the token out of the state= field, and measure (read-only) why ancestry proof failed on a live Codex seat. Done when self-locate no longer always returns undetermined reason=not_found via emit_observe.

Written by the indexing model from the issue text.

Description

What

fix.sh falls back to agmsg_token_locate_self (scripts/lib/token-locate.sh) when the process-ancestry proof cannot place the seat. That function prints a token to its own stdout and then, inside the same call, reads every pane the census can reach to find the token.

When fix.sh runs as an agent's tool call, the agent CLI renders the command's output only after the command returns. So during that call the token is not in any pane yet, and the result is always undetermined reason=not_found.

Observed

A Codex seat asked to self-fix:

fix seat=<team>/<agent> state=AGMSG_LOCATE_TOKEN(<team>/<agent>): agmsg-locate-a1237322
undetermined reason=not_found via=emit_observe (written nothing)

Measured from a Claude Code seat on herdr, with no fix.sh involved:

  • Printed a token, waited 2s, and read the seat's own pane in the same tool call: 0 matches.
  • Read the same pane again after that call returned: 1 match.

The file's own header already says that reading on a timer misses the token, and that the caller must wait for the seat's completion signal before reading. The fallback in the same file does not do that.

A side issue: the state= field in the line above shows the token line rather than a state. The token printed to stdout seems to be captured into the state field.

To do

  1. Split emit and observe into two steps. One call prints the token and returns. A later call, made after the seat's own turn has rendered, reads the panes. How the seat triggers the second step (a second fix.sh invocation, or a follow-up the agent runs) is open.
  2. Find out why the ancestry proof failed for this Codex seat. Codex's process tree may not reach the herdr pane from a tool call. Measure it on a live Codex seat (read-only).
  3. Fix the state= field so the token line does not end up in it.

Seat identity feeds poke and the monitor, so a seat that cannot place itself cannot be poked reliably.

Dominant language
Shell
Stars
1.5k
Forks
156
Avg merge
16h 23m
Merged PRs (30d)
197

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fujibee/agmsg

All issues in fujibee/agmsg

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.