GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(streaming): tag streamed events with agent_path by vkalmathscale · Pull Request #474 · scaleapi/scale-agentex-python

Conversation

@vkalmathscale

@vkalmathscale vkalmathscale commented Jul 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Why

Streamed lifecycle and text events carry only a task_id. When multiple agents share one task stream (for example, child-workflow sub-agents emitting into a parent orchestrator's stream), their events are indistinguishable at the consumer. The only identity-ish field is author (Literal["user","agent"]), a role, not a source.

What

Thread an optional agent_path (str | list[str]), a single agent id or a root-to-emitter path like ["researcher", "subagent-abc"], end to end:

  • Wire: TaskMessage.agent_path on the envelope, stamped on the in-memory message after messages.create(), so every start/delta/full/done event carries it via parent_task_message. No change to the messages.create/update client contract (stream-only tag).
  • Propagation: ContextInterceptor gains a streaming_agent_path ContextVar plus a context-agent-path header, threaded from workflow to activity independently of the task/trace/span gate (a child workflow can set only _agent_path). This lets the offloaded model activity tag live text and reasoning deltas.
  • Emission: TemporalStreamingHooks takes agent_path and forwards it on tool-request, tool-response, and handoff; stream_lifecycle_content and the streaming service/facade pass it to the envelope; TemporalStreamingModel reads the ContextVar for its three streaming contexts.

Backward compatible

agent_path defaults to None (untagged) everywhere. Existing callers, including subclasses that call super().__init__(task_id=..., timeout=...), are unaffected.

Depends on scaleapi/scale-agentex#381 (do not merge standalone)

The TaskMessage.agent_path wire field is authored upstream in the backend OpenAPI spec (scaleapi/scale-agentex#381). The edit to src/agentex/types/task_message.py in this PR is a temporary manual patch so the branch is functional and testable now; merging a hand-edited generated type would be wiped on the next Stainless regen.

Merge order:

  1. Merge scale-agentex#381 (backend schema plus regenerated openapi.yaml).
  2. Stainless auto-regenerates this SDK on next, adding agent_path to the generated types/task_message.py.
  3. This PR is rebased to drop the manual types/task_message.py patch, leaving only the lib/ runtime.

Verification

  • py_compile clean on all touched files; lint (ruff/FA102) fixed.
  • Runtime: TaskMessage.agent_path serializes correctly for str, list[str], and the None default via model_dump(mode="json").
  • Deeper Temporal-runtime checks (header round-trip, replay) should run in a bootstrapped env.

Follow-ups (not in this PR)

  • Consumers read parent_task_message.agent_path through a single toPath(x) = Array.isArray(x) ? x : [x] normalizer (for the str | list union).
  • Multi-agent consumers with nested sub-agents adopt agent_path (the parent sets each child's path) and retire any bespoke per-agent attribution workaround.

Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
stainless-app Bot and others added 7 commits July 17, 2026 17:23
@stainless-app
feat(stlc): configurable CI runner and private-production-repo suppor…
23c1b6b
…t in workflow templates
@stainless-app
codegen metadata
3c7015e
@stainless-app
feat(api): add include_live parameter to schedules list method
199fd6a
@NiteshDhanpal @claude
[WIP] feat(tracing): correlate business spans with active observabili…
c67e177
…ty trace (#465)

Co-authored-by: Claude Opus 4.8 <[email protected]>
@stainless-app
fix(api): remove params field from task list response
152bc75
@declan-scale
feat(codex): republish todo_list revisions as they are ticked off (#473)
0252fcc
@vkalmathscale
feat(streaming): tag streamed events with agent_path
901ea97
Streamed lifecycle/text events carried only a task_id, so events from
multiple agents sharing one task stream (e.g. child-workflow sub-agents
emitting into the orchestrator's stream) were indistinguishable.

Thread an optional agent_path (str | list[str]) end to end:
- TaskMessage envelope carries it, so every start/delta/full/done event
  is attributable via parent_task_message.
- ContextInterceptor propagates it workflow->activity via a new
  ContextVar + header, so the model activity tags live text/reasoning deltas.
- TemporalStreamingHooks + stream_lifecycle_content + streaming service
  stamp it on tool/lifecycle events.

Backward compatible: agent_path defaults to None (untagged) everywhere.

NOTE: task_message.py is Stainless-generated; the agent_path field is a
manual stopgap and must be mirrored in the upstream OpenAPI spec
(.stats.yml openapi_spec_url) or the next regen will drop it.
greptile-apps[bot]
greptile-apps Bot reviewed Jul 28, 2026
View reviewed changes
Comment thread src/agentex/types/task_message.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vkalmathscale
fix(streaming): add future annotations import to activities
d45bc60
@stainless-app
stainless-app Bot force-pushed the next branch from 0252fcc to 2b7649c Compare July 28, 2026 19:05
@vkalmathscale vkalmathscale mentioned this pull request Jul 28, 2026
feat(task-messages): add optional agent_path to TaskMessage scaleapi/scale-agentex#381
Open
@stainless-app
stainless-app Bot force-pushed the next branch from bc51c52 to 761833e Compare September 18, 2026 21:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vkalmathscale @NiteshDhanpal @declan-scale
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.