Skip to main content

🧰 BobKit for Python

Developer toolkit 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

BobKit 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 bobkit

🚀 Quickstart: One-Liner Bob.invoke

import asyncio
from bobkit 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 bobkit 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 bobkit 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 bobkit 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 bobkit 1.0.0
File Size Uploaded Provenance Actions
bobkit-1.0.0.tar.gz 18.0 kB Without provenance Details for bobkit-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 36.1 kB

Release files / bobkit-1.0.0.tar.gz

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

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

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

Security for bobkit 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