Skip to content

interactive harness: drop -newer filter on session JSONL parser - #614

Merged
max-sixty merged 1 commit into
mainfrom
token-usage-fix
May 27, 2026
Merged

max-sixty merged 1 commit into
mainfrom
token-usage-fix

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Why

Smoke 3 (https://github.com/max-sixty/tend/actions/runs/26489730646) succeeded end-to-end — Stop hook fired, claude responded Smoke test ran at 2026-05-27T03:54:20Z in 8s — but the token-usage step reported 0 turns and emitted a ::warning::. The find predicate -newer "$RUNNER_TEMP/tend-run-claude.sh" excluded the session JSONL because its mtime was equal-or-older than the wrapper script's (mtime tie on the GHA runner filesystem; both files created within sub-second precision).

What

Drop the -newer filter. The step runs on an ephemeral CI runner where ~/.claude/projects is freshly populated by THIS run only — no prior sessions to accidentally pull in, so the filter was paranoia without benefit.

Tiny one-line fix; comment in the action explains why we don't filter.

Smoke 3 (run 26489730646) succeeded end-to-end — Stop hook fired,
claude responded "Smoke test ran at 2026-05-27T03:54:20Z" in 8s — but
the token-usage step reported 0 turns. Root cause: the find predicate
`-newer "$RUNNER_TEMP/tend-run-claude.sh"` excluded the session JSONL
because its mtime was equal-or-older than the wrapper script's
(precision tie on the GHA runner's filesystem).

The step runs on an ephemeral CI runner where `~/.claude/projects` is
freshly populated by THIS run only; no prior sessions exist to
accidentally pull in. Drop the filter.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit c711bc1 into main May 27, 2026
6 checks passed
@max-sixty
max-sixty deleted the token-usage-fix branch May 27, 2026 04:10
max-sixty added a commit that referenced this pull request May 27, 2026
## Why

Smoke 4 (https://github.com/max-sixty/tend/actions/runs/26490407419)
succeeded end-to-end — Stop hook fired, claude responded `Smoke test ran
at 2026-05-27T04:16:42Z` in 8s — but the token-usage step still reported
`0 turns`, even after the `-newer` filter fix in #614.

Root cause is the jq filter itself:

```jq
[.[] | .[] | select(.message.usage)] as $msgs
```

`jq -s` slurps all input files into ONE flat array of events. The second
`.[]` tried to iterate event OBJECTS (yielding their values, not
events), which hit `Cannot index string with string "message"` on the
first non-object value. The `|| echo '{}'` swallowed the error and the
step fell through to zeros.

Verified against the actual smoke 4 session JSONL (downloaded from the
run's artifact):

| | buggy parser | fixed parser |
|---|---|---|
| stderr | `Cannot index string with string "message"` | (clean) |
| stdout | (nothing → `{}` fallback) |
`{"input_tokens":5,"output_tokens":269,"cache_creation_input_tokens":14531,"cache_read_input_tokens":44341,"turns":3,"model":"sonnet","cost_usd":0}`
|

## What

Single fix: drop one `.[]` from both the `$msgs` accumulator and the
turns count. Add a comment so future-me doesn't make the same mistake.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty max-sixty mentioned this pull request May 27, 2026
max-sixty added a commit that referenced this pull request May 27, 2026
## Why

Cut the 0.1.2 release so consumer repos (and tend's own nightly regen)
pick up the new
`claude-interactive` harness and per-workflow `harness`/`model`
overrides.

## What's new since 0.1.1

**New `claude-interactive` harness**
(`max-sixty/tend/[email protected]`) — opt-in
alternative to the released `claude` harness. PTY-supervised interactive
`claude` via
`script(1)`, end-of-turn detected through Stop/StopFailure hooks. Built
as the
trial path ahead of Anthropic's June 15 billing split between Agent-SDK
metering and
the flat Claude Code subscription. Smoke tested end-to-end on tend
itself. PRs:
#609, #611, #613, #614, #615, #616.

**Per-workflow `harness` / `model` override** — adopters can flip a
single workflow
to a different harness or model without changing `.config/tend.yaml`
defaults. #612.

**Skill refinements** — nightly upstream-bot rebases (#605),
running-in-ci PR bar
(#604) and recheck (#573), env-filter loophole fix (#599),
authorAssociation warning
(#600), review-gates Gate 1 (#602).

**Bug fix** — mention queue-delay now uses `comment.updated_at` so edit
events report
accurately (#595).

## Compatibility

Released `claude` harness path is byte-identical; `claude-interactive`
is strictly
additive and opt-in. Consumer repos that don't touch `harness:` see no
change beyond
the new skill text and the mention-edit fix.
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.

2 participants