Skip to main content

This tutorial walks you through wiring a LangChain agent with a tool that executes shell commands in a K7 sandbox.

Prerequisites#

  • K7 API running (k7 install deploys it by default; from a laptop check GET /health or k7 api status after k7 config set) and reachable
  • API key generated: k7 generate-api-key <name> --role user --tenant <tenant> (on a cluster node; --role is required since 0.5.0 — in development mode you may omit --tenant, in production every user key needs one)
  • Python 3.10+

Setup#

Create a .env file with your credentials and defaults:

Install dependencies (LangChain 1.x — initialize_agent was removed):

Agent code#

Tip

You can exec into the same sandbox in parallel: k7 exec lc-agent -- ls /. k7 shell is node-local.