sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[P1 items] Python & TypeScript SDK Parity tracking issue

Open notowen333 opened this issue 7 months ago • 7 comments

This issue serves to track parity items which have been triaged as non-P0 features

notowen333 avatar Apr 22 '26 16:04 notowen333

Python ↔ TypeScript parity — gap analysis (for tracking)

⚠️ Source & caveat: the following was derived from an automated agent analysis of the two SDK trees (strands-py/ and strands-ts/) and their reference docs. It has not been hand-verified — treat every line as a lead to confirm against current code before acting, not as ground truth. Line/behavior claims may be stale or wrong.

Framing: TypeScript is the newer interface — a number of things learned in Python were applied differently in TS on purpose. We can't break Python, so feature parity is the goal where it makes sense, but some differences are deliberate and should be left alone. Split accordingly:

Close — TS is missing (port Python → TS)

  • Tool registry + filesystem loader + hot-reload (ToolWatcher) — TS has no local tool registry/loader/watcher (only MCP onToolsChanged).
  • Sliding-window tool-pair trim fallback (_find_tool_pair_trim_point) — no TS equivalent.
  • Concurrency/idempotency dedup + result replay (owner-aware lock) — TS has only a boolean acquireLock(). Partly tracked by #3018.
  • Summarizing-via-sub-agent path; per_turn proactive management.
  • Swarm repetitive-handoff detection.

Close — Python is missing (port TS → Python)

  • Backoff/jitter strategy library.
  • ExecuteToolStage + AgentStreamStage middleware + middleware interrupt path (Python only wraps the model call via InvokeModelStage).
  • LifecycleObserver extension point.
  • Richer tool-result truncation (typed placeholders, document-source-aware).
  • MCP elicitation as a first-class client feature.
  • Snapshot-based session model (UUID-v7 immutable history).
  • Vended tools: http-request, notebook.
  • First-class logging module.

Leave alone — deliberate divergence, NOT parity work

  • Model-provider breadth (Python ships ~12 native providers; TS ships ~6 + the Vercel adapter). Explicitly not porting providers.
  • Vercel AI SDK adapter.
  • Graph/Swarm join semantics (OR/AND-join, batches vs per-node scheduling, tool-based vs structured-output handoff).
  • Schema philosophy: Pydantic (Py) vs Zod (TS).
  • Python sync↔async bridge (run_async) — required by Python's sync entrypoint; N/A in TS.
  • TS Data-interface/companion-class type pattern.
  • TS browser-first packaging.

Already tracked separately

  • Durable execution / checkpoint parity: #3040 (+ sub-issues #3047–#3051), under epic #2510.

Next step: an owner should confirm each "close" item against current code and convert the confirmed ones into checklist entries / linked issues here.

yonib05 avatar Jul 01 '26 02:07 yonib05

@pgrayy but really strandly port

yonib05 avatar Jul 01 '26 13:07 yonib05

@strandly-the-agent can you review this ticket? Then review each SDK in Python and TypeScript for differences that we should include in this task.

yonib05 avatar Jul 09 '26 18:07 yonib05

Parity re-verification (July 9) — the July 1 auto-analysis is now partly stale

TL;DR: I re-checked every "close" item in the July 1 gap analysis against current code (strands-py/ vs strands-ts/), plus swept both trees for new gaps. The SDKs have converged since then — TS gained registry/, retry/, middleware/, logging/, and context-manager/. Net result: 3 listed items are wrong/no-longer-gaps, 3 narrowed, the rest confirmed, and I found ~15 differences not on the list. Corrected breakdown below — still agent-produced, so confirm before converting to checklist items, but this time every claim is grounded in a file:line I read.

⚠️ Corrections to the existing list (these changed)

  • MCP elicitation — NOT a gap, remove it. Python has it: elicitation_callback param + server -32042 handling (strands-py/.../tools/mcp/mcp_client.py:213,865,941). Present in both SDKs.
  • "Backoff/jitter library" (Py missing) — half wrong. Python already does exponential backoff (event_loop/_retry.py:76, initial_delay * 2**attempt). The real TS→Py gap is jitter + a pluggable backoff/retry-strategy library (strands-ts/src/retry/backoff-strategy.ts), not backoff itself.
  • "TS has no tool registry/loader/watcher" — narrowed. TS now has a real ToolRegistry (CRUDL, strands-ts/src/registry/tool-registry.ts:7). Remaining Py→TS gap is just the filesystem/directory loader + ToolWatcher hot-reload (strands-py/.../tools/watcher.py:19).
  • "Richer tool-result truncation" (Py missing) — narrowed. Python does truncate (image placeholder + text). The TS-only extras are video / document-source-aware / json placeholders (strands-ts/.../sliding-window-conversation-manager.ts:54,67,80).
  • LifecycleObserver — minor. Python has the functional equivalent via HookProvider.register_hooks (hooks/registry.py:113); only the named agent-scoped observeAgent(agent) hook is TS-only.
  • per_turn — nuance. The message-count per_turn mode is Py-only, but proactive compression (token-ratio threshold) exists in both — reviewers shouldn't conflate them.

Confirmed as-listed: _find_tool_pair_trim_point (Py→TS), summarizing-via-sub-agent (Py→TS), concurrency dedup/replay owner-aware lock vs bare acquireLock() (Py→TS, partly #3018), swarm repetitive-handoff detection (Py→TS), middleware ExecuteToolStage/AgentStreamStage+interrupt (TS→Py), snapshot/UUID-v7 session (TS→Py), vended http-request+notebook (TS→Py), first-class logging/ module (TS→Py).

New differences not on the list (grounded in file:line)

Py → TS (missing in TS):

  • experimental/bidi/ — bidirectional / realtime streaming. Biggest gap: BidiAgent + Nova Sonic / OpenAI Realtime / Gemini Live providers (strands-py/.../experimental/bidi/). No TS equivalent.
  • experimental/checkpoint/ — durable-execution checkpoints (Checkpoint, CheckpointPosition). Relates to epic #2510 / #3040.
  • MCP tool filtering + name-prefixing — ToolFilters (allowed/excluded/regex/callback) + prefix (mcp_client.py:75,109). No TS option.
  • ToolProvider lifecycle interface (tools/tool_provider.py:11) — no TS analog.
  • Pluggable tool-executor class hierarchy — Py ToolExecutor(ABC) is subclassable (tools/executors/_executor.py:32); TS is a fixed 'sequential'|'concurrent' enum.
  • Max-tokens partial-message recovery — recover_message_on_max_tokens_reached sanitizes truncated tool_use blocks (event_loop/_recover_message_on_max_tokens_reached.py:16); TS just throws MaxTokensError.
  • Concurrency modes — THROW / UNSAFE_REENTRANT (agent/_concurrency.py:125); TS has one throw-on-reentry behavior.
  • config_to_agent declarative-config factory; handlers/ callback handlers (PrintingCallbackHandler etc.); telemetry metrics_to_string + Trace timeline class. (handlers/ is arguably deliberate — TS uses async-generator streaming instead.)

TS → Py (missing in Python):

  • MCP OAuth auth — auth / authProvider (strands-ts/src/mcp/client.ts:71,113). No Python equivalent.
  • Pluggable RetryStrategy abstraction + jitter (see correction above).
  • Graph maxConcurrency semaphore (strands-ts/src/multiagent/graph.ts:52) — Py graph runs each batch fully parallel with no cap.
  • Cedar namespace config for namespaced policy types (vended-interventions/cedar/cedar.ts:45) — Py always flattens the schema. Looks accidental / not-yet-ported.
  • warnOnce dedup utility (part of the logging/ module).
Deliberate divergence — confirmed, leave alone (not parity work)
  • Model providers: Py ships 12 native classes; TS ships 5 native + the Vercel adapter, which covers LiteLLM/Mistral/Ollama/LlamaCpp/LlamaAPI/SageMaker/Writer via @ai-sdk/provider. Confirmed intentional.
  • Graph/Swarm semantics: Py = OR-join + batch scheduling + tool-based handoff; TS = AND-join + per-node scheduling + structured-output handoff. Documented as intentional in the TS headers (graph.ts:105, swarm.ts:109).
  • Steering placement: Py ships it as a Plugin (plugins:); TS ships it as an InterventionHandler (interventions:). Action vocab also differs (Py Proceed|Guide|Interrupt vs TS Proceed|Guide|Confirm).
  • Callback-handler pattern (Py) vs async-generator streaming (TS); Pydantic vs Zod; run_async sync↔async bridge; TS data-interface/companion-class pattern; TS browser-first packaging. All as previously noted.
Already tracked elsewhere

Durable execution / checkpoint parity → #3040 (+ #3047–#3051) under epic #2510. Both the TS→Py snapshot/UUID-v7 session model and the Py→TS experimental/checkpoint/ item above sit in this space and should be reconciled against that epic rather than tracked twice.

Happy to open individual issues for the confirmed "close" items or draft checklist entries here — say the word and point me at which direction you want prioritized.

strandly-the-agent avatar Jul 09 '26 18:07 strandly-the-agent

@strandly-the-agent Can you create individual issues using the Port template and link them to this parent issue?

Be sure you include as much detail on what needs to be migrated as possible and complete the port template as detailed as possible

yonib05 avatar Jul 09 '26 18:07 yonib05

Port issues from the parity audit — both directions

Each issue is filled to the Port template (Source/Target/Related Files/Confirmation) plus detailed what-to-migrate, landing points, and open questions. Every source feature is verified merged + unit-tested (integ/docs status called out per-issue).

TS → Py (“Python is missing”) — 9 issues

  • [ ] #3150 — Middleware pipeline: ExecuteToolStage + AgentStreamStage + interrupt path (large; deep interrupt-infra work)
  • [ ] #3151 — Pluggable retry/backoff-strategy library with jitter (back-compat: ms-vs-seconds, abstract-vs-concrete rename)
  • [ ] #3152 — First-class logging module + warn_once (needs a design decision — injectable-global vs Python idiom)
  • [ ] #3154 — Vended tool: http_request (clean; needs httpx dep)
  • [ ] #3153 — Vended tool: notebook (clean; pure stdlib)
  • [ ] #3155 — MCP client OAuth authentication (blocker: no client_credentials provider in Python mcp)
  • [ ] #3156 — Graph max_concurrency cap (port the cap concept only, not the scheduler)
  • [ ] #3157 — Cedar namespace configuration (additive; docs already say “Python planned”)
  • [ ] #3158 — Richer tool-result truncation placeholders (type-system blockers: no video/text-document in Py types)

Py → TS (“TypeScript is missing”) — 9 issues + 1 epic (now that the template supports this direction 🙌)

  • [ ] #3163 — Tool filesystem loader + directory discovery + hot-reload watcher (Node-only; ES-module-cache hot-reload gap)
  • [ ] #3161 — MCP tool filtering + name-prefixing (regex anchoring trap: re.match vs RegExp.test)
  • [ ] #3162 — ToolProvider lifecycle interface (needs a new agent dispose/cleanup API; doc gap)
  • [ ] #3166 — Pluggable tool-executor class hierarchy (refactor TS enum → subclassable base)
  • [ ] #3165 — Sliding-window tool-pair trim fallback (small, well-scoped)
  • [ ] #3164 — Summarizing-via-sub-agent path (blockers: LocalAgent has no invoke(), readonly toolRegistry)
  • [ ] #3167 — per_turn proactive conversation management (no TS conversation-manager session-state mechanism)
  • [ ] #3168 — Swarm repetitive-handoff detection (decision: soft-FAIL vs throw)
  • [ ] #3170 — Max-tokens partial-message recovery (architectural: TS throws in the model layer before history)
  • [ ] #3169 — [EPIC] Bidirectional / realtime streaming (experimental/bidi) — phased plan, not a single port (experimental source; Nova Sonic likely browser-infeasible — needs a go/no-go)

Excluded / deferred (deliberately not filed)

  • Already tracked: concurrency modes (THROW/UNSAFE_REENTRANT) + idempotency dedup/replay → #3018; durable-execution / snapshot session model → epic #2510 / #3040. Not double-tracked.
  • Deferred (low value): telemetry metrics_to_string — the Trace timeline class already exists in TS as AgentTrace; only an undocumented pretty-printer is missing, and ms-vs-seconds / None-vs-0 differences make it a reimplementation, not a translation. Say the word if you want it.
  • Deliberate divergences left alone: model-provider breadth/Vercel adapter, Graph/Swarm join semantics, steering placement, callback-handler pattern vs async-generator streaming, Pydantic-vs-Zod, run_async bridge, browser-first packaging. Also skipped LifecycleObserver (Python already has the functional equivalent via HookProvider) and Python handlers/ callback handlers (deliberate — TS streams via async generators).

Label: thanks for creating port + updating the template. I still can't apply the label via the API (the guardrail can't resolve label node-ids), so all 19 issues need the port label applied manually — sorry for the manual step.

Happy to adjust scope, split/merge any, or kick off the bidi phases 1–3 as individual [PORT] tickets — just point me at what to prioritize.

strandly-the-agent avatar Jul 09 '26 19:07 strandly-the-agent

Filed #3779 as a child of this tracker: [PARITY] Duplicate tool names: Python silently overwrites (hot-reload allowance), TS throws. Verified by running both SDKs at bf275c7 — two same-named @tools in Agent(tools=[a, b]) leave Python with one tool and no warning (second wins, via the supports_hot_reload allowance in tools/registry.py:250), while new Agent({ tools: [a, b] }) throws ToolValidationError in TS (registry/tool-registry.ts:33).

Two things need a maintainer — strandly-the-agent gets FORBIDDEN on addSubIssue and addLabelsToLabelable with both of its credentials:

  1. Link #3779 as a sub-issue of this issue. It's currently only a cross-reference, so it's absent from this tracker's sub-issue list unlike every other child.
  2. Apply the missing labels on #3779: sdk-parity, typescript, to-refine. It already carries bug, python, area-devx, area-tool — and bug is arguably wrong: this is a parity/design decision with two candidate directions, not a defect.

strandly-the-agent avatar Aug 12 '26 15:08 strandly-the-agent