Skip to main content

The Strands Agents (Python) adapter for Welt's wire contract

Project description

welt-io

pypi python

This project has been renamed to welt-io-strands. Install welt-io-strands and import welt_io_strands instead — this package stays published for existing installs but receives no further releases.

The Strands Agents (Python) adapter for Welt's wire contract — one of Welt's agent-side adapters.

Install

uv add welt-io

Usage

See examples/agent — the smallest complete agent built on this package (text streaming, image generation, file input, and a human-approval tool), which doubles as the example for Welt's Quick Start. The sections below explain the adapters it wires in.

API

The wire between Welt and the agent is JSON, specified by Welt's wire contract — plain Strands values do not fit it in either direction. Two functions adapt the inbound payload, three the outbound stream.

Inbound

decode_messages(messages)

Returns a copy of Welt's Converse-shaped messages with the base64-encoded file bytes restored to the raw bytes Strands expects; the input is left untouched. Its in-place predecessor, decode_file_blocks(messages), is deprecated.

decode_interrupt_responses(responses)

Turns Welt's resume payload — a mapping of interrupt id to the answer a human chose — into the interruptResponse items that Agent.stream_async resumes from.

Outbound

renderable_events(events)

Reduces raw stream_async events — not JSON-serializable as-is — to the events Welt renders:

Strands emits On the wire In the Slack thread
Text deltas data The streamed reply
Tool invocations and results current_tool_use / tool_result "Using tool" indicators (tool output stays off the wire)
Image / document / video blocks a tool or the model produces file An uploaded file (size limits)
Pending interrupts interrupt Buttons and/or a text field

A run that stops for human input ends its stream with one interrupt event per pending interrupt; agents that do not use interrupts see no change.

file_event(name, data)

Builds the same file event from a filename and raw bytes, for attaching arbitrary files of your own:

yield file_event("report.csv", csv_bytes)

Tool-generated files need no code at all — for example, strands-tools' generate_image returns the image as a tool-result block, which streams into the thread by itself. The example agent includes it.

interrupt_reason(message, options=..., input=...)

Builds the structured reason Welt renders as a message with the specified widgets — choice buttons (options), a free-text field (input), or both. The specs are the wire's own shapes; omitted fields keep Welt's defaults, and a typo becomes an immediate ValueError instead of a silent fallback to Welt's default rendering:

answer = tool_context.interrupt(
    "deploy-approval",
    reason=interrupt_reason(
        "Deploy to prod?",
        [
            {"value": "y", "label": "Deploy", "style": "primary"},
            {"value": "n", "label": "Cancel"},
        ],
        input={"label": "Or tell me what to do instead"},
    ),
)

Working with interrupts

Welt's Interrupts doc covers the Slack side: how each reason renders, who can answer, multiple questions, and expiry. On the Strands side:

  • Prefix your interrupt names (myapp-deploy-approval). Hook-raised interrupts must be unique across the whole event, tool-raised ones within their tool — a prefix keeps both as the agent grows.
  • Strands' ready-made HumanInTheLoop intervention works over Welt as-is. Its string reasons render with Welt's default Approve / Deny buttons, whose y / n values its default evaluator understands. Do not pass ask: stdio prompts and callback evaluators have no terminal on AgentCore Runtime.
  • Route stdio consent prompts through interrupts instead. For strands-tools packages that gate themselves behind a stdio prompt, set BYPASS_TOOL_CONSENT=true and let HumanInTheLoop do the gating over Slack. The strands-tools handoff_to_user tool is likewise stdio-bound; a small interrupt-raising tool of your own is the replacement.

Supported Versions

Welt releases first; welt-io follows, mirroring the minor version. While both are 0.x, a welt-io 0.Y release supports Welt v0.Y — other combinations may work, but come with no guarantee.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

welt_io-0.3.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

welt_io-0.3.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file welt_io-0.3.2.tar.gz.

File metadata

  • Download URL: welt_io-0.3.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for welt_io-0.3.2.tar.gz
Algorithm Hash digest
SHA256 724b7600396b5c9e6739075824ef09828cf83d07ea3a5a73b679ad440307a59d
MD5 57d91de652d21704451a4ecf5d8873dc
BLAKE2b-256 37b369e5b41e8500009fa9c1b6bb3d02e22e431edbda33661f1fa956a4eb561b

See more details on using hashes here.

File details

Details for the file welt_io-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: welt_io-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for welt_io-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 28220c153bfc609bb0c1d9a06806447aae7edfd1a2784f21d9c65a3c15c426b4
MD5 26ff081db4fb1013d7f01dead4e97cb6
BLAKE2b-256 66ae7facccb078cd5d43e97c987760ed2dbb96111bf7e700d66f6e40ce2e5bb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page