Skip to content

feat(python): ScriptedTool bindings + LangChain integration#219

Merged
chaliy merged 1 commit intomainfrom
claude/python-langchain-integration-B0qPO
Feb 18, 2026
Merged

feat(python): ScriptedTool bindings + LangChain integration#219
chaliy merged 1 commit intomainfrom
claude/python-langchain-integration-B0qPO

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 18, 2026

Summary

  • ScriptedTool Python class: PyO3 wrapper that registers Python callbacks as bash builtins. Each callback receives (params: dict, stdin: str | None) with typed flag parsing (integers, booleans, strings coerced per JSON schema).
  • LangChain integration: ScriptedToolLangChain wrapper + create_scripted_tool() factory for use with LangChain ReAct agents.
  • k8s orchestrator example: Single-file demo with 12 fake kubectl commands (get_pods, get_nodes, scale_deployment, etc.) and 6 bash orchestration scripts. Optional --langchain flag for ReAct agent demo.
  • 26 new Python tests covering construction, execution, jq pipelines, error handling, stdin pipes, env vars, loops, conditionals, async, introspection, and 12-tool orchestration.

Test plan

  • cargo fmt --check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo test --all-features passes (68 passed)
  • ruff check + ruff format --check passes
  • pytest tests/ -v passes (47 tests: 21 existing + 26 new)
  • python examples/k8s_orchestrator.py runs and prints correct output for all 6 demos

- Add ScriptedTool Python class wrapping Rust ScriptedTool via PyO3
  - add_tool() registers Python callbacks as bash builtins
  - Callbacks receive (params: dict, stdin: str | None) -> str
  - JSON<->Python conversion for typed flag parsing (int, bool, str)
  - execute/execute_sync run bash scripts with all registered tools
  - Introspection: system_prompt(), help(), description(), schemas
- Add ScriptedToolLangChain wrapper and create_scripted_tool() factory
- Add k8s_orchestrator.py example: 12 fake kubectl commands, 6 demos
  - get_nodes, get_namespaces, get_pods, get_deployments, get_services
  - describe_pod, get_logs, get_configmaps, get_secrets, get_events
  - scale_deployment, rollout_status
  - Optional LangChain ReAct agent integration (--langchain flag)
- Add 26 Python tests covering construction, execution, pipelines,
  jq integration, error handling, stdin, env vars, loops, conditionals,
  async, introspection, and 12-tool orchestration
- Enable scripted_tool feature in bashkit-python Cargo.toml
- Update type stubs and __init__.py exports

https://claude.ai/code/session_0117wzNc2aRc5chtBgfwgdCd
@chaliy chaliy merged commit 36dc727 into main Feb 18, 2026
15 checks passed
@chaliy chaliy deleted the claude/python-langchain-integration-B0qPO branch February 18, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants