Repository navigation
fix(strands): give Strands the worker model's id and context window (breaking) - #158
Merged
Merged
Conversation
`TemporalModel.getConfig()` returned `{}` because the real model lives on
the worker. Strands reads `contextWindowLimit` from it in workflow code for
proactive compression, so every `TemporalAgent` compressed at 70% of the
200,000-token fallback, whatever its model: a model with a larger window
lost turns a native agent keeps, and a smaller one kept turns it drops.
Agent and model spans also had no model id.
`TemporalAgent.initialize()` now reads the worker model's `modelId` and
`contextWindowLimit` through a new `strandsGetModelConfig` activity, with
the agent's activity options, before Strands initializes the agent.
`TemporalModel.getConfig()` returns them. Only these two fields are
returned, so provider settings such as API keys stay out of history.
The read is behind the `strands-agents.model-config` patch. Agents that an
open run initialized before this version keep the empty config, and
`initialize()` returns Strands' own promise without awaiting anything
first, so the run schedules its commands in the same order and replays; agents it creates afterwards read the config. Runs that read
the config cannot be replayed by an earlier version. To roll back, keep
this version and decline the patch with the worker's
`patchActivationCallback`.
Breaking change: each `TemporalAgent` schedules one more activity, and
compression now uses the model's real window. Applications that scaled
`compressionThreshold` by window / 200,000 to work around the missing
limit must remove that scaling, or they compress too early.
This was referenced Oct 26, 2026
Fixes add no version gates for now, so remove the `strands-agents.model-config` patch. Every `TemporalAgent` now reads the worker model's config before its first model call, in every run. Breaking change: the read is a new activity. A run whose agent ran before this version schedules `strandsGetModelConfig` on replay where its history has `invokeModel`, and fails with a nondeterminism error. Let those runs finish before you upgrade, or use Worker Versioning.
campoy
marked this pull request as ready for review
October 28, 2026 21:39
brianstrauch
approved these changes
Oct 28, 2026
brianstrauch
left a comment
Member
There was a problem hiding this comment.
Looks good to me. Optional follow-up to round out test coverage across this PR and #194:
- In #158, add automated checks for credential exclusion, retrying after a failed config read, and the documented replay mismatch with a pre-change history.
- In #194, add a compression regression like this PR's two-turn test, asserting which messages reach the second model call.
These suggestions are non-blocking and can be handled in a follow-up.
This was referenced Oct 28, 2026
campoy
added a commit
that referenced
this pull request
Oct 28, 2026
Follow-up to #158: - The test model's config holds an API key, and the workflow sees only the model id and context window. - After a failed config read, the agent's next turn reads it again. - A history recorded before the read (helloAgent on 73deca0) fails to replay with [TMPRL1100], as the README says.
This was referenced Oct 29, 2026
campoy
added a commit
that referenced
this pull request
Nov 16, 2026
npm already has @temporalio/strands-agents 1.24.0 from the SDK repo, so its next release is 2.0.0, not 1.0.0. The four histories recorded after #158 move to 2.x/. The one recorded before #158 has 1.24.0's behavior, so it stays in 1.x/ and no longer replays, and the test that checked it fails goes away.
campoy
added a commit
that referenced
this pull request
Nov 16, 2026
#565) ## What was changed Replay is promised only within a major version now. A history recorded on a 1.x release must replay on every later 1.x release, and nothing is promised from 1.x to 2.x. So why does CI still replay 1.x histories on code that's heading to 2.0? It shouldn't, and this PR stops it. - Each plugin's committed histories move into a folder per major, `histories/<major>.x/`. - Each replay test gets a `REPLAY_MAJOR` constant (`ReplayMajor` in C#) and loads only that folder. Older majors' folders stay in the repo, but they don't replay. - AGENTS.md gets the rule, next to the one about gating history changes. A plugin's current major is the major of its next release. Here's what I used: | Plugin | Latest release | Current major | Replays | Kept, not replayed | | --- | --- | --- | --- | --- | | `python/openai_agents` | 1.1.0, then `Breaking:` commits | 2 | 4 histories in `2.x/` | 12 in `1.x/` | | `typescript/openai-agents` | 1.24.0 on npm (published from the SDK repo), then `Breaking:` commits | 2 | 1 in `2.x/` | 4 in `1.x/` | | `typescript/vercel-ai-sdk` | 1.0.0, then `Breaking:` commits | 2 | none | 3 in `1.x/` | | `python/google_genai` | 1.0.0rc1 | 1 | 1 in `1.x/` | 1 in `0.x/` | | `typescript/strands-agents` | none from this repo (npm has 1.21.0 to 1.24.0 from the SDK repo); 2.0.0 next | 2 | 4 in `2.x/` | 1 in `1.x/` | | `typescript/google-adk` | 0.1.0; 1.0.0 next | 1 | 2 re-recorded in `1.x/` | 2 in `0.x/` | | `python/google_adk` | 0.0.1; 1.0.0 next | 1 | none | 7 in `0.x/` | | `python/strands_agents` | 0.1.0; 1.0.0 next | 1 | 4 in `1.x/` | 5 in `0.x/` | | `python/deepagents` | 0.0.3; 1.0.0 next | 1 | none | 3 in `0.x/` | | `java/google-adk`, `dotnet/microsoft-agent-framework`, `python/microsoft_agent_framework` | below 1.0, not 1.0 next | 0 | all, in `0.x/` | none | A history recorded on `main` before a breaking fix goes with the release whose behavior it recorded. So the five OpenAI Agents Python histories from before #204, #373 and #426, and the four TypeScript ones from before #373, are 1.x histories. Strands Python's four MCP histories were recorded after #190 moved its MCP Activities to `temporalio-mcp`, code that 0.1.0 never had, so they're 1.x histories too. Strands TypeScript's `hello-agent-before-model-config` was recorded before #158, so it has 1.24.0's behavior and is a 1.x history. Its other four were recorded after #158, so they're 2.x. Tests that replayed only older-major histories go: Vercel AI SDK's three committed-history tests, Google GenAI's `legacy_ascii_files` replay, Google ADK Python's two replay tests with their workflows, Strands Python's `test_legacy_history_replay.py` and `test_model_context_overflow_legacy_replay.py`, Deep Agents' `test_legacy_cache_replay.py`, and Strands TypeScript's test that its history from before #158 fails to replay. The OpenAI Agents lists keep only the current major's files. Google ADK TypeScript's replay test checks a live run against a checked-in fixture, so I recorded its two fixtures again into `1.x/` with its own `UPDATE_ADK_HISTORIES=1`. `go/googleadk` doesn't change: it has no committed histories, and its replayer tests replay runs the same test just recorded. ## Why? We decided that replay is promised only within a major. But CI still replayed 1.x histories, so a fix for 2.0 had to keep 1.x runs replaying behind a patch, even though we don't promise that. With this PR, the next one can remove those patches from OpenAI Agents Python before 2.0.0 ships. ## Checklist 1. No issue. 2. How was this tested: - Python, for each of the six plugins: `make sync`, `make format`, `make lint`, and the tests that read committed histories (3, 7, 43, 11, 4 and 42 passed). - TypeScript, for each of the four plugins, in Docker with Node 24: `make sync`, `make lint`, and the test files that read committed histories. - `check_conventions.py` passes, and `detect_changes.py` selects the 12 plugins. - After moving the 1.0-next plugins to major 1: Google ADK Python `make format`, `make lint` and `make test` (321 passed, 6 skipped); Google ADK and Strands TypeScript `make lint` and their replay tests, in Docker with Node 24. - After moving Strands Python and Deep Agents to major 1 and merging `main`: `make lint` and `make test` for both (277 and 261 passed). - After moving Strands TypeScript to major 2: `make lint` and its two replay test files, in Docker with Node 24 (8 passed). - Java and .NET didn't run locally (no JDK or .NET SDK on this machine). CI runs them. 3. Any docs updates needed? AGENTS.md has the rule. The Microsoft Agent Framework Python histories README says where recordings go now.
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.
What was changed
TemporalAgent.initialize()reads the Worker model'smodelIdandcontextWindowLimitthrough a newstrandsGetModelConfigActivity, with the agent's Activity options, before Strands initializes the agent.TemporalModel.getConfig()returns them, so Strands' proactive compression and its agent and model spans see the real values.TemporalModel.loadConfig()runs the read once per model. It returnsundefinedwhen the config was already read, andinitialize()then returns Strands' owninitialize()promise.compressionThresholdscaling to undo, and the upgrade note below.Why?
TemporalModel.getConfig()returned{}, so Strands' conversation manager in Workflow code used a 200,000-token window for every model (#157). A model with a larger window lost turns a native agent keeps; a smaller one kept turns it drops.Breaking change
compressionThresholdby window / 200,000 to work around the missing limit must remove that scaling, or they compress too early. The plugin cannot tell that scaling from a chosen low threshold.TemporalAgentschedules one more Activity before its first model call, also agents without compression, because the spans read the model id from the same config.strandsGetModelConfigon replay where its History has the agent's first command (invokeModel, or an Activity from anInitializedEventhook), so it fails with[TMPRL1100]. Open runs fail their Workflow Tasks; finished runs fail when they are replayed. Runs that create their first agent after the upgrade, and runs without aTemporalAgent, are not affected.The commit messages state the breaking change. The PR title says it too, because release notes come from the squash commit subject.
Upgrade: let runs whose agents already ran finish on the earlier version before you upgrade, or keep them there with Worker Versioning. The same applies to rolling back: an earlier version does not read the config, so runs that read it are not expected to replay there.
Checklist
Closes [Bug] strands-agents (TypeScript): proactive compression ignores the model's context window #157
How was this tested:
TemporalAgent gives Strands the worker model id and context windowintest-strands.ts. Onmainit fails on both parts (config{}, and the second model call still carries turn 1). With this change it passes.main, and passes with this change, with the locked@strands-agents/sdk1.19.0 and with 1.6.0.mainhistory starts its agent's turn withinvokeModel, or with anInitializedEventhook's Activity, and every history recorded with the read starts it withstrandsGetModelConfig. Without the gate, amainhistory therefore meets the new Activity as its first new command; the check's control, one extra Activity first, fails with[TMPRL1100].make sync,make lint,make test(34 tests),make build, the npm package check, the smoke install andcheck_conventions.pypass, and Prettier with the SDK settings reports the files clean. The Node 22, macOS and Windows cells did not run locally.Any docs updates needed?
The plugin README has two new paragraphs. Release notes must carry the
compressionThresholdmigration note and say that runs whose agents ran before this version, or after it on a rollback, do not replay across the change.Not covered
TemporalModel.countTokensstill uses Strands' estimate, not the Worker model's native token count.TemporalModel.statefulis stillfalse. The same Activity could return the Worker model'sstatefulflag in a later change.TemporalModelused with a plain StrandsAgentdoes not read the config.mainhistories on this change, and of its histories onmain, was not rerun after the gate was removed.Open questions
strandsGetModelConfigcannot take over a caller's Activity.getModelConfigwould matchinvokeModel, but it is a common name.TemporalModel.loadConfig()be public or internal?