Skip to main content

🧰 BobStack for Python

Developer stack and Python client for the Bob Agent Client Protocol (ACP).

Build autonomous coding assistants, IDE tools, streaming agent workflows, and terminal bots directly on top of Bob ACP without requiring any middleman server.


✨ Features

  • ⚡ Direct ACP Connection: Directly launches and speaks JSON-RPC 2.0 with bob acp via standard I/O (stdio).
  • 🌊 Stream-First AsyncIterables: Consume token deltas smoothly with async for chunk in stream:.
  • 🎮 Full Control Channels:
    • Cancel Channel: Immediately aborts inference locally and dispatches session/cancel to Bob ACP.
    • Intermediate Steering Channel: Dynamically steer ongoing agent execution mid-turn.
  • 🔧 First-Class Tool & Thought Events: Listen to live reasoning (on_thought), tool calls (on_tool_call), stdout/stderr chunks (on_tool_output), and results (on_tool_result).
  • 🔄 Stateful Sessions & Mode Switching: Multi-turn conversation management with dynamic switching between agent, ask, and plan modes.
  • 🛡️ Zero Runtime Dependencies: Built with standard library (asyncio, subprocess, json).

📋 Prerequisites

BobStack speaks directly with the Bob CLI (bob acp). Ensure you have:

  1. Node.js >= 22
  2. Bob CLI (@ibm/bob) installed globally:
    npm install --registry=https://registry.npmjs.org/ --allow-scripts=@officecli/officecli -g @ibm/bob
    
  3. Python >= 3.9

📦 Installation

pip install bobstack

🚀 Quickstart: One-Liner Bob.invoke

import asyncio
from bobstack import Bob

async def main():
    # 1. One-liner invocation (automatically spawns `bob acp`)
    stream = await Bob.invoke(
        "Write a Python script to check for prime numbers",
        mode="agent",
        on_thought=lambda thought: print(f"💭 [Thinking] {thought}"),
        on_tool_call=lambda tool: print(f"🔧 [Tool] {tool.name}: {tool.parameters}")
    )

    # 2. Stream tokens in real-time
    async for chunk in stream:
        print(chunk, end="", flush=True)

    # 3. Await final result and stop reason
    result = await stream.result()
    print(f"\nFinished: {result.stop_reason}")

if __name__ == "__main__":
    asyncio.run(main())

🎛️ Control Channels (Pause, Resume, Cancel, Steer)

import asyncio
from bobstack import Bob

async def main():
    stream = await Bob.invoke("Generate a detailed architectural analysis of a microservices backend")

    # 1. Pause & Resume (backpressure control without losing data)
    stream.pause()
    stream.resume()

    # 2. Intermediate Steering (inject guidance mid-flight)
    await stream.send_intermediate_message("Make sure to focus on Redis caching!")

    # 3. Cancel (stop agent execution immediately)
    await stream.cancel()
    print(stream.is_cancelled)  # True

    async for chunk in stream:
        print(chunk, end="", flush=True)

if __name__ == "__main__":
    asyncio.run(main())

💬 Stateful Sessions & Mode Switching

import asyncio
from bobstack import BobClient

async def main():
    client = BobClient()
    await client.connect()

    # 1. List active sessions
    sessions = await client.list_sessions()
    print(f"Active sessions: {len(sessions)}")

    # 2. Create session in 'agent' mode
    session = await client.create_session(mode="agent")

    # Turn 1:
    turn1 = await session.chat("Create a new index.ts file with an express server")
    async for chunk in turn1:
        print(chunk, end="", flush=True)

    # Switch mode to 'ask' for Q&A
    await session.set_mode("ask")

    # Turn 2 (context preserved!):
    turn2 = await session.chat("Explain the route structure you created")
    async for chunk in turn2:
        print(chunk, end="", flush=True)

    # View history
    print(session.get_history())

    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

📜 License

Apache-2.0

Metadata

Release files for bobstack 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bobstack 1.0.0
File Size Uploaded Provenance Actions
bobstack-1.0.0.tar.gz 18.0 kB Without provenance Details for bobstack-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bobstack 1.0.0
File Interpreter ABI Platform Actions
bobstack-1.0.0-py3-none-any.whl Python 3 none any Details for bobstack-1.0.0-py3-none-any.whl

Total release size: 36.2 kB

Release files / bobstack-1.0.0.tar.gz

Download URL bobstack-1.0.0.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7f0e5ed47d96568c70814fdb0d466b96fcf08a1a08b6cea9df53e019207030cb
BLAKE2b-256 checksum
How to use checksums
ed8d932a6b43c4664b637468b0d22480fb266c5fcac6f8979251461c14cc0bca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / bobstack-1.0.0-py3-none-any.whl

Download URL bobstack-1.0.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
089b34d137d4e283c2998df2ae81ddbd1b59f060ae6be0caacef0e39569d3ccf
BLAKE2b-256 checksum
How to use checksums
c60f15f0f9b2ca68f9e6361f4a1453012ff9c6f368e7da8e4456e3dc824a9451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for bobstack 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page