Skip to main content

input() for Claude Code agents

Project description

PyPI version Python versions License Coverage

Claude Dentist Rating

python-agent-input

input() for Claude Code agents.

Claude Code hangs on input() because it cannot write to stdin. agent_input() replaces input() with an HTTP server — it prints curl instructions to stdout and blocks until the agent responds.

Important: Since agent_input() blocks, the agent must run the script in the background with Bash, then use the TaskOutput tool with block=false to check its stdout for curl instructions.

Usage

from python_agent_input import agent_input

name = agent_input("What is your name?")
print(f"Hello, {name}!")

Input validation

from python_agent_input import agent_input


def celsius_or_kelvin(value: str) -> str:
    if value not in ("Celsius", "Kelvin"):
        raise ValueError(f"Expected 'Celsius' or 'Kelvin', got '{value}'")
    return value


temp = agent_input("Temperature in Fahrenheit?", example_response="72", validate=int)
unit = agent_input("Convert to Celsius or Kelvin?", validate=celsius_or_kelvin)

if unit == "Celsius":
    print(f"{(temp - 32) * 5 / 9:.1f}°C")
else:
    print(f"{(temp - 32) * 5 / 9 + 273.15:.1f}K")

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

python_agent_input-0.0.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

python_agent_input-0.0.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file python_agent_input-0.0.4.tar.gz.

File metadata

  • Download URL: python_agent_input-0.0.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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":null}

File hashes

Hashes for python_agent_input-0.0.4.tar.gz
Algorithm Hash digest
SHA256 dd4f566fbc90eaa05d54508de4c19c01f084b813a1b2e06a562e4074b1214d70
MD5 c2140524087513e76d04acba74f00d5a
BLAKE2b-256 2024f704af2df0d6b3b5afd3877e9a71435c3120ac7694286cb9657bdde03a29

See more details on using hashes here.

File details

Details for the file python_agent_input-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: python_agent_input-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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":null}

File hashes

Hashes for python_agent_input-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 802eb557314b0011fa1b996b35970989f18628c5f92095dc10acb0a7d162498f
MD5 ec4a4b4c1290f71fcf5e21126a9f9ce2
BLAKE2b-256 88622019e7ec4e5cbf8a1e0408ea2d26e05e878713785146d997994c1cf4d3b7

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