Repository navigation
chore: move to strands-agents 1.67's context manager and stop using conversation managers - #677
Merged
Merged
Conversation
added 3 commits
November 25, 2026 11:09
…ontext_manager strands-agents 1.67.0 graduates the context manager out of `strands.experimental` (strands-agents/harness-sdk#6509): the experimental module and the "stash" config key still work, with a DeprecationWarning, and are removed in 1.68.0. Reflection now imports `ContextState` and `Offload` from `strands.context_manager` and turns off the archive with `"archive": False` (was `"stash": False`). Neither exists in 1.66, so the floor moves to strands-agents>=1.67.0. Conversation managers are not deprecated (the SDK's docs keep them, with an optional migration), so InteractionsEvaluator's SlidingWindowConversationManager stays.
…managers
Conversation managers are on their way out in favor of the SDK's
`context_manager=`, so the optimizer's tests and docstring examples stop
using them:
- The smoke test and the CLI fixture tune a bundle of parameters
(`component(dict, ...)`) the agent factory turns into a `context_manager=`
config: `Offload.drop("*").when(preserve_recent=...)` under `window`,
`Offload.summarize("*").when(context_utilization=...)` under `summary`.
The tuned keys are `manager.window.preserve_recent` and
`manager.summary.context_utilization`, with the old defaults (40, 0.3), so
the scripted model's numbers and every pick are unchanged.
- The declaration tests swap a real `ContextManager` through its
constructor (`archive=OneOf(None, False)`, whose None default stands in
for `pin_first`'s), and the fixed-alternative copy test uses a plain
object.
- The `component()` and `ParamInfo` docstring examples use context managers.
InteractionsEvaluator still uses SlidingWindowConversationManager.
…, not a sliding window
The judge used SlidingWindowConversationManager(window_size=num_interactions).
The window counts messages and each judged interaction adds 3, so the judge
only saw the previous interaction, and from the third one on it had lost the
first prompt, the only one carrying <Input> when inputs aren't per-interaction.
It now passes context_manager= with Offload.drop("*").when(preserve_recent=
num_interactions) and no archive: before each model call the judge keeps its
first message and the newest num_interactions messages, the ones between
becoming one [Dropped] marker. A test runs a real judge Agent on a scripted
model, sync and async, and fails on the old window.
nhungbi
requested a deployment
to
manual-approval
November 25, 2026 16:33 — with
GitHub Actions
Waiting
nhungbi
marked this pull request as ready for review
November 25, 2026 16:34
nhungbi
requested a deployment
to
manual-approval
November 25, 2026 16:35 — with
GitHub Actions
Waiting
liramon2
requested a deployment
to
manual-approval
November 25, 2026 16:52 — with
GitHub Actions
Waiting
liramon2
approved these changes
Nov 25, 2026
arielnabavian
approved these changes
Nov 25, 2026
arielnabavian
approved these changes
Nov 25, 2026
poshinchen
approved these changes
Nov 25, 2026
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
strands-agents 1.67.0 moves the context manager out of
strands.experimental(strands-agents/harness-sdk#6509). The old import path and the"stash"config key still work, with aDeprecationWarning, and are removed in 1.68.0. This PR moves to the new names and raises the floor tostrands-agents>=1.67.0, sincestrands.context_managerand"archive"don't exist in 1.66.Conversation managers are next to go, so this PR also removes every use of them in
src/, the tests, and the docstrings.Reflection (
optimization/search/reflection.py):ContextStateandOffloadfromstrands.context_manager."stash": Falsebecomes"archive": False.context_utilization="85%"becomes0.85(the SDK parses both the same way).InteractionsEvaluator: behavior change. The judge agent usedSlidingWindowConversationManager(window_size=num_interactions). The window counts messages, and each judged interaction adds 3 (prompt, structured-output call, result). So the judge only ever saw the previous interaction, and from the third interaction on it had lost the first prompt, the only one that carries<Input>when inputs aren't per-interaction.It now passes
context_manager={"strategies": [Offload.drop("*").when(preserve_recent=num_interactions)], "archive": False}. Before each model call the judge keeps its first message and the newestnum_interactionsmessages, and the ones between become one[Dropped]marker. The judge therefore sees the task input on every interaction, and somewhat more recent context than before, so scores can shift. The SDK has no exact equivalent of the old window (its docs say so).Tests and docstring examples:
component(dict, ...)bundle that the agent factory turns into acontext_manager=config:Offload.dropunderwindow,Offload.summarizeundersummary. The tuned keys becomemanager.window.preserve_recentandmanager.summary.context_utilization. They keep the old defaults (40, 0.3), so the scripted model's numbers and every pick are unchanged.ContextManagerthrough its constructor (archive=OneOf(None, False), whoseNonedefault stands in forpin_first's).component()andParamInfodocstring examples and AGENTS.md use context managers.Related Issues
strands-agents/harness-sdk#6509
Type of Change
Breaking change: the dependency floor moves to
strands-agents>=1.67.0, andInteractionsEvaluator's judge sees different context.Testing
Against strands-py
maininstalled as 1.67.0: the fulltests/strands_evalssuite passes, 5434 passed and 1 skipped (1.67.0 isn't on PyPI yet, sohatch testcan't resolve the floor). No warning about the deprecated names comes from this repo's code. Ruff passes, and mypy passes on the changed modules.New
test_the_judge_keeps_the_first_prompt_and_the_newest_messages: runs a real judgeAgenton a scripted model, sync and async. It asserts the judge keeps the input prompt, a[Dropped]marker, and the newest interaction. It fails onmainbecause the window had dropped the input.Context window warning: on a model whose context window Strands doesn't know, the context manager prints its 200,000-token fallback warning. The default judge model (
global.anthropic.claude-sonnet-4-6) has a known window (1,000,000), so it doesn't.I ran
hatch run prepare. It can't resolvestrands-agents>=1.67.0until 1.67.0 is published.Known, not in this PR:
strands-harness0.4.0 and 0.5.0 (theoptimizationextra allows>=0.4,<0.5) still importstrands.experimental.context_manager. That warns on 1.67 and breaksstrands-evals optimize --configand agent files at 1.68.0. harness-sdkmainhas already moved tostrands.context_manager. The extra's range needs widening once a fixed harness release ships, orstrands-agentsneeds a<1.68cap until then.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.