"Hierarchical Context Management" Reproducibility?
Hi Z.AI Team, thank you so much for open-sourcing such impressive models and sharing your research!
I have 2 clarifying questions about the context management strategies described in Section 4.2.4 of the tech report, in order to help ensure community reproducibility of the BrowseComp/HLE results.
Question 1) What exactly is discarded in Discard-all?
In Section 4.2.4, you state:
“we discard the entire tool-call history and restart with a fresh context”
Could you clarify precisely what is removed when Discard-all is triggered?
Given a trajectory (as described in the paper):
(q, r_1, a_1, o_1, r_2, a_2, o_2, ..., r_n, a_n, o_n)
Where:
q= questionr_i= reasoning at round ia_i= actiono_i= observation
Does Discard-all reset the context to one of the following?
Scenario A — Keep only system prompt + initial question
(system_prompt, q)
Meaning everything else is discarded:r_i, a_i, o_i for all i.
Scenario B — Remove only observations
(system_prompt, q, r_1, a_1, r_2, a_2, ..., r_n, a_n)
Meaning:o_i discarded for all i.
Scenario C — Remove all tool-related content (actions + observations)
(system_prompt, q, r_1, r_2, ..., r_n)
Meaning:a_i and o_i discarded for all i.
Or is there another variant intended?
Question 2) Interaction between Discard-all and keep-recent-k in HCM
In Section 4.2.4, "Hierarchical Context Management" is described as:
“During inference with keep-recent, if the total context length exceeds a threshold T, we discard the entire tool-call history and restart with a fresh context, while continuing to apply the keep-recent strategy.”
Would you be able to provide clarification on the control flow logic? I see 3 plausible interpretations:
Interpretation 1 — Discard-all triggered once, keep-recent always active
- keep-recent-k is active from the start.
- If
len(context) > T:- Trigger Discard-all once.
- After restart:
- keep-recent-k continues to apply.
- Discard-all is never triggered again.
Pseudocode:
discarded_once = False
while not done:
if len(context) > T and not discarded_once:
context = discard_all(context)
discarded_once = True
context = apply_keep_recent_k(context, k)
Interpretation 2 — Discard-all triggered every time T is exceeded
- keep-recent-k always active.
- Whenever
len(context) > T:- Trigger Discard-all.
- This can happen multiple times during inference.
Pseudocode:
while not done:
if len(context) > T:
context = discard_all(context)
context = apply_keep_recent_k(context, k)
Interpretation 3 — keep-recent-k activated only after first Discard-all
- Initially, no keep-recent-k.
- If
len(context) > T:- Trigger Discard-all.
- Activate keep-recent-k.
- After that:
- keep-recent-k remains active.
- Discard-all is never triggered again.
Pseudocode:
keep_recent_active = False
discarded_once = False
while not done:
if len(context) > T and not discarded_once:
context = discard_all(context)
discarded_once = True
keep_recent_active = True
if keep_recent_active:
context = apply_keep_recent_k(context, k)
Or is there another interpretation intended?
Thanks again for any clarifications you are able to provide, and for your amazing work! 🙏