Skip to content

chore: move to strands-agents 1.67's context manager and stop using conversation managers - #677

Merged
nhungbi merged 5 commits into
strands-agents:mainfrom
nhungbi:fix/strands-agents-1.67
Nov 25, 2026
Merged

nhungbi merged 5 commits into
strands-agents:mainfrom
nhungbi:fix/strands-agents-1.67

Conversation

@nhungbi

@nhungbi nhungbi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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 a DeprecationWarning, and are removed in 1.68.0. This PR moves to the new names and raises the floor to strands-agents>=1.67.0, since strands.context_manager and "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):

  • Imports ContextState and Offload from strands.context_manager.
  • "stash": False becomes "archive": False.
  • context_utilization="85%" becomes 0.85 (the SDK parses both the same way).

InteractionsEvaluator: behavior change. The judge agent used SlidingWindowConversationManager(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 newest num_interactions messages, 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:

  • The smoke test and the CLI fixture tune a component(dict, ...) bundle that the agent factory turns into a context_manager= config: Offload.drop under window, Offload.summarize under summary. The tuned keys become manager.window.preserve_recent and manager.summary.context_utilization. They keep 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).
  • The component() and ParamInfo docstring 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, and InteractionsEvaluator's judge sees different context.

Testing

  • Against strands-py main installed as 1.67.0: the full tests/strands_evals suite passes, 5434 passed and 1 skipped (1.67.0 isn't on PyPI yet, so hatch test can'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 judge Agent on a scripted model, sync and async. It asserts the judge keeps the input prompt, a [Dropped] marker, and the newest interaction. It fails on main because 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 resolve strands-agents>=1.67.0 until 1.67.0 is published.

Known, not in this PR: strands-harness 0.4.0 and 0.5.0 (the optimization extra allows >=0.4,<0.5) still import strands.experimental.context_manager. That warns on 1.67 and breaks strands-evals optimize --config and agent files at 1.68.0. harness-sdk main has already moved to strands.context_manager. The extra's range needs widening once a fixed harness release ships, or strands-agents needs a <1.68 cap until then.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published (needs strands-agents 1.67.0 on PyPI)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

nhungbi 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
nhungbi deployed to auto-approve November 25, 2026 16:33 — with GitHub Actions Active
@github-actions github-actions Bot added chore Maintenance tasks, dependency updates, CI changes, refactoring with no user-facing impact area-community Repo health, governance, contributor process, release process, and CI dependency bumps labels Nov 25, 2026
@nhungbi
nhungbi marked this pull request as ready for review November 25, 2026 16:34
@nhungbi
nhungbi requested a review from a team as a code owner November 25, 2026 16:34
@nhungbi
nhungbi requested a review from mkmeral November 25, 2026 16:34
@nhungbi
nhungbi merged commit 2a255bc into strands-agents:main Nov 25, 2026
19 of 20 checks passed

This branch is waiting to be deployed

1 active and 1 waiting deployments
manual-approval — cabb6ec6 Waiting Nov 25, 2026 by liramon2 via Trigger Strands Review #972
auto-approve — cabb6ec6 Deployed Nov 25, 2026 by liramon2 via Run integration tests #1279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-community Repo health, governance, contributor process, release process, and CI dependency bumps chore Maintenance tasks, dependency updates, CI changes, refactoring with no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants