Skip to main content

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

Project description

welt-io

pypi python

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, and its contract is defined by Welt's docs — plain Strands values do not fit it in either direction. Each function below adapts one piece:

Inbound

decode_file_blocks(messages) restores the base64-encoded file bytes in Welt's Converse-shaped messages (built from Slack uploads) back to the raw bytes Strands expects, in place. Without uploads it is a no-op.

decode_interrupt_responses(responses) turns Welt's resume payload — a plain 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: text chunks (data), tool-use indicators (current_tool_use / tool_result, slimmed so text tool output stays off the wire), and generated files (file, a filename plus base64 bytes for each image/document/video block a tool or the model produces, which Welt uploads to the Slack thread — see Welt's Files doc for size limits and rendering). A stream that stops for human input (interrupts) ends with one interrupt event per pending interrupt, which Welt renders as buttons in the Slack thread; 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 reason shape Welt renders as a message with the specified widgets, both specs being the wire's own shapes: buttons (options, one dict per button — a required value, an optional label, an optional style of "primary" or "danger"), a free-text field whose submitted text becomes the response (input — an optional label and multiline), or both — whichever answer comes first settles the question. Omitted fields keep Welt's defaults; building the shape through this helper turns a typo into 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"},
    ),
)

Welt's Interrupts doc covers the whole round trip: the reason contract, who can press, multiple interrupts, and expiry. Prefix your interrupt names (myapp-deploy-approval): hook-raised interrupts must be unique across the whole event, tool-raised ones within their tool, and 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. For strands-tools packages that gate themselves behind a stdio consent prompt, set BYPASS_TOOL_CONSENT=true and let HumanInTheLoop do the gating over Slack instead; the strands-tools handoff_to_user tool is likewise stdio-bound, and 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.0.tar.gz (13.8 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.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: welt_io-0.3.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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.0.tar.gz
Algorithm Hash digest
SHA256 98f2055a12327cccb582b0249f0a7c2b00d2813bba6366f9bcd5c9db58a62fc0
MD5 94fad472915bd1a036c0adc28f2f71ac
BLAKE2b-256 155dac3bca397490e2f053bc2292d463ff3d760f2f34f116aaf56caf3479d1a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: welt_io-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bf385e2c0c1f46dd140750645bd590f8fc99353b77b8e7df78935993dc29376
MD5 361fada533f1711dec4da4002da7ad9d
BLAKE2b-256 c51a5f1c2a64d9b0ad156d35ac9577af7fc9d006f099dd4f5cfcebac93bdbe01

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