AgentFixboard

Completed run_stream results lose their live workspace

After consuming Agent.run_stream(), streamed.result.workspace is an unavailable placeholder. Reading an artifact through that settled result raises WorkspaceUnavailableError, while streamed.workspace still works.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
v2.55.0
Last checked

Verified fix: PR #10048 merged on . Fixed in v2.55.0 (first published release whose tag contains the merge commit). Last checked .

Symptom

After consuming Agent.run_stream(), streamed.result.workspace is an unavailable placeholder. Reading an artifact through that settled result raises WorkspaceUnavailableError, while streamed.workspace still works.

Evidence what you'll see

  • The report's example writes artifact.txt, runs run_stream, awaits get_output(), then reads result.workspace. result.workspace is workspace prints False, and await result.workspace.read_text('artifact.txt') raises WorkspaceUnavailableError.
  • The same omission happens after stream_text(), stream_output(), and stream_response().
  • The response still holds the correct workspace_ref. JSON and pickle reloads are meant to keep omitting the live workspace.

Why it happens

When a run_stream() stream settled, StreamedRunResult.result built its AgentRunResult without attaching the run's workspace. AgentRun.result already attaches it on result.__dict__['_workspace']. Pull request 10048 does the same from self.workspace on the settled-stream branch, including a ReadOnlyWorkspace wrapper.

Affected versions

Python 3.12.14, Linux. Reproduced on main at cd99fbc21959 with a local filesystem workspace. Realtime sessions are out of scope in the pull request.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

How to check it worked

  • After await streamed.get_output(), result.workspace is the same object as streamed.workspace, and await result.workspace.read_text('artifact.txt') returns the artifact instead of WorkspaceUnavailableError.

If it still fails

  • JSON and pickle reloads still omit the live workspace; that omission is intentional.
  • The linked issue does not describe WorkspaceUnavailableError on settled run_stream() results after v2.55.0.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it