Skip to content

feat(cli): expose context-window occupancy in headless JSON; emphasize no-poll guidance - #18

Merged
ygyang11 merged 2 commits into
mainfrom
feat/headless-context-tokens
Jul 8, 2026
Merged

ygyang11 merged 2 commits into
mainfrom
feat/headless-context-tokens

Conversation

@ygyang11

@ygyang11 ygyang11 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Two small, independent changes bundled into one PR.

1. Headless JSON — final context-window occupancy (cli)

The headless JSON result line carried only cumulative usage tokens (total spend across all calls), with no way to read how full the context window ended up. Add a context object sourced from collect_window(agent) — the same view /context renders:

"context": { "input_tokens": <displayed_input_tokens>, "max_tokens": <max_tokens> }
  • Only on the success result line; the is_error line and text mode are untouched.
  • input_tokens is null when no LLM call happened (honest).
  • agent.context/short-term memory survive aclose(), so reading the window after cleanup is safe.

2. Background-task no-poll emphasis (harness, app)

Uppercase the "DO NOT NEED TO POLL OR CHECK PROACTIVELY" guidance in the background_task tool description and the prompt section, to more firmly discourage the agent from polling for results that are delivered automatically.

Test

  • ruff check src tests — clean
  • mypy src — clean (207 files)
  • pytest tests/unit — 2592 passed

ygyang11 added 2 commits July 8, 2026 16:45
The headless JSON result line carried only cumulative usage tokens. Add a
context object ({input_tokens, max_tokens}) sourced from collect_window — the
same view /context renders — so consumers can read the final window occupancy,
not just total token spend.
@ygyang11
ygyang11 merged commit cb3bb3c into main Jul 8, 2026
5 checks passed
@ygyang11
ygyang11 deleted the feat/headless-context-tokens branch July 8, 2026 08:51
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