#1671

fix(core): bound the parent history a child agent inherits

Openlxcxjxhxwants to merge intofrom

Fixes #1645 (option B from the report; the parent-side pre-spawn compaction in option A is a separate change and is not included).

child_initial_input serialized the parent's whole history into the child's first user message with json.dumps — no token counting, no truncation. Compaction runs in the child's first _run_cycle, after that message exists, so a long parent run could overflow the child's window on its very first model call.

  • newest inherited messages are kept up to INHERITED_CONTEXT_MAX_TOKENS (8k), counted with the same count_tokens the compaction path uses;
  • the block starts with how many messages were dropped, so the child knows the background is partial rather than complete;
  • an oversized newest message is still rendered — an empty block would hide that the parent had context at all;
  • the spawn site passes the child's model, so the count uses that tokenizer instead of the UTF-8 byte fallback.

Validation (pytest tests/test_inputs.py -q -> 57 passed):

caseresult
history under the budgetrendered whole, no omission note
6 messages over a 10-token budgetonly the newest kept, 5 earlier inherited message(s) omitted
one oversized newest messagestill rendered
no historyblock absent (unchanged)

Reverting inputs.py fails the trimming cases and keeps the under-budget and no-history cases green, which pins that a normal spawn renders exactly what it did before. pytest tests/ -k 'child or inputs or spawn' -> 73 passed, 3 failed; the 3 (test_runner_mcp, test_runner_teardown) fail identically with these changes stashed — an unrelated SimpleNamespace has no attribute 'telemetry' fixture error in this checkout. ruff check + format clean.

Activity

6
greptile-apps[bot]1d ago

Confidence Score: 4/5

[Medium impact] The change affects the starting context of spawned child agents.

The PR appears safe to merge, with two non-blocking improvements to history selection and budget counting.

Findings

  1.  Retained history has hidden gaps ▶
  2.  Rendered history exceeds its budget ▶
Fix with agent prompt
### Issue 1
strix/core/inputs.py:363-365
`continue` skips a message that does not fit, then tries older messages. With a small newest message, a large middle message, and a small oldest message, the child receives the newest and oldest but loses the middle. This can preserve an old conclusion while dropping its correction. The omission note also wrongly says only earlier messages were removed.

Stop at the first item that does not fit and count the remaining older items as dropped. Add a mixed-size history test.

### Issue 2
strix/core/inputs.py:362
The budget counts each item's JSON separately, but the child receives a JSON list. The list adds brackets and separators, and counting the pieces separately can also change token boundaries. Even when no retained item is oversized, the rendered history can exceed `max_inherited_tokens`.

Check the complete rendered list against the budget and add a boundary test using several messages.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Limits the background history passed to child agents and adds an omission note.

  • Child agents inherit recent parent history within an 8,000-token budget.

Acknowledged scope: lxcxjxhx explicitly intends to retain an oversized newest message. The author also defers parent-side compaction to a separate change.

Verification used source inspection; no tests were run during this review.

Reviews (1) · Last reviewed commit: "fix(core): bound the parent history a ch..." · Reviewed by Greptile

greptile-apps[bot]reviewed1d ago
lxcxjxhxreviewed1d ago
lxcxjxhxreviewed1d ago