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

[PORT] Vended tool: http_request (TS→Py)

Open strandly-the-agent opened this issue 4 months ago • 3 comments

⚠️ Filed by Strandly as part of the #2498 parity audit. Source feature verified merged + unit-tested + integ-tested + documented in strands-ts. Agent-produced — confirm before implementing. (No port label yet — a maintainer should add it.)

Parent: #2498

Source SDK

strands-ts

Target SDK

strands-py

Related Files

strands-ts/src/vended-tools/http-request/http-request.ts
strands-ts/src/vended-tools/http-request/types.ts
strands-ts/src/vended-tools/http-request/index.ts
strands-ts/src/vended-tools/http-request/README.md
strands-ts/src/vended-tools/index.ts
strands-ts/src/vended-tools/http-request/__tests__/http-request.test.ts
strands-ts/test/integ/tools/http-request.test.ts
site/src/content/docs/user-guide/concepts/tools/vended-tools.mdx
site/src/content/docs/user-guide/concepts/tools/vended-tools.ts
site/src/content/docs/user-guide/concepts/tools/vended-tools-imports.ts

What needs to be migrated

The http_request vended tool (http-request.ts:39). Python vended_tools/ has only bash + file_editor.

Input schema (http-request.ts:7): method (required enum GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS), url (required, URL-validated), headers (optional Record<string,string>), body (optional string), timeout (optional positive number, seconds, default 30).

Behavior: builds abort signal from timeout*1000 combined with the agent cancel signal; fetch(url, {method, signal, headers?, body?}); reads body as text; flattens response headers; throws HTTP {status} {statusText}: {method} {url} on non-2xx; timeout/cancel error messages.

Output (types.ts:34): {status, statusText, headers, body}.

Python landing points

New package strands-py/src/strands/vended_tools/http_request/ (snake_case), mirroring bash/: __init__.py (exports http_request), http_request.py (@tool(name="http_request", ...) with type-hinted params — Literal[...] for method, int=30 for timeout), types.py (TypedDict output). Register in vended_tools/__init__.py (__all__). Update vended-tools.mdx support matrix (currently TS-only) + add a Python tab. Not sandbox-routed; no make_* factory needed.

Gotchas / open questions

  • HTTP client: TS uses native fetch; Python has no stdlib async client. Best fit is httpx (async) — confirm adding it as a dependency (requests is sync, would block the loop). Decorator supports async def.
  • Redirects: fetch follows redirects by default; httpx does not — set follow_redirects=True for parity.
  • response.ok: replicate as 200<=status<300, raise otherwise (mirror bash.py RuntimeError idiom).
  • Cancellation: TS combines timeout with agent.cancelSignal; verify whether strands-py exposes an agent cancel mechanism before promising parity — at minimum honor timeout.

Completeness of source (strands-ts)

  • Merged: ✅ · Unit tests: ✅ (bodies, header flattening, 2xx/3xx/4xx/5xx, timeout/network errors) · Integ: ✅ (test/integ/tools/http-request.test.ts, real endpoint).
  • Docs: ✅ in shared vended-tools.mdx (marked TS-only — update on port) + README; no dedicated per-tool .mdx.

Confirmation

  • [x] The change is complete in the source SDK (merged + unit + integ tested + documented); every related artifact is listed above.

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

@strandly-the-agent implement

arielnabavian avatar Jul 21 '26 18:07 arielnabavian

Looks like this is being worked on here https://github.com/strands-agents/harness-sdk/pull/3395.

arielnabavian avatar Jul 21 '26 18:07 arielnabavian

Duplicate of https://github.com/strands-agents/harness-sdk/issues/3238

arielnabavian avatar Jul 21 '26 18:07 arielnabavian