Pygent is a minimalist coding assistant that runs commands in a Docker container when available and falls back to local execution. See https://marianochaves.github.io/pygent for documentation and https://github.com/marianochaves/pygent for the source code.
Project description
Pygent
Pygent is a coding assistant that executes each request inside an isolated Docker container whenever possible. If Docker is unavailable (for instance on some Windows setups) the commands are executed locally instead. Full documentation is available in the docs/ directory and at marianochaves.github.io/pygent.
Features
- Runs commands in ephemeral containers (default image
python:3.12-slim). - Integrates with OpenAI-compatible models to orchestrate each step.
- Persists the conversation history during the session.
- Provides a small Python API for use in other projects.
- Optional web interface via
pygent-ui. - Register your own tools and customise the system prompt.
Installation
Installing from source is recommended:
pip install -e .
Python ≥ 3.9 is required. The package now bundles the openai client for model access.
To run commands in Docker containers also install pygent[docker].
Configuration
Behaviour can be adjusted via environment variables (see docs/configuration.md for a complete list):
OPENAI_API_KEY– key used to access the OpenAI API. Set this to your API key or a key from any compatible provider.OPENAI_BASE_URL– base URL for OpenAI-compatible APIs (defaults tohttps://api.openai.com/v1).PYGENT_MODEL– model name used for requests (defaultgpt-4.1-mini).PYGENT_IMAGE– Docker image to create the container (defaultpython:3.12-slim).PYGENT_USE_DOCKER– set to0to disable Docker and run locally.PYGENT_MAX_TASKS– maximum number of concurrent delegated tasks (default3).
Settings can also be read from a pygent.toml file. See
examples/sample_config.toml
and the accompanying
config_file_example.py
script for a working demonstration that generates tests using a delegated agent.
CLI usage
After installing run:
pygent
Use --docker to run commands inside a container (requires
pygent[docker]). Use --no-docker or set PYGENT_USE_DOCKER=0
to force local execution.
Pass --config path/to/pygent.toml to load settings from a file.
Type messages normally; use /exit to end the session. Each command is executed
in the container and the result shown in the terminal.
Interactive programs that expect input (e.g. running python without a script)
are not supported and will exit immediately.
For a minimal web interface run pygent-ui instead (requires pygent[ui]).
API usage
You can also interact directly with the Python code:
from pygent import Agent
ag = Agent()
ag.step("echo 'Hello World'")
# ... more steps
ag.runtime.cleanup()
See the examples folder for more complete scripts. Models can be swapped by
passing an object implementing the Model interface when creating the
Agent. The default uses an OpenAI-compatible API, but custom models are
easy to plug in. They can also trigger tools by returning a message with
tool_calls as demonstrated in examples/custom_model_with_tool.py.
Using OpenAI and other providers
Set your OpenAI key:
export OPENAI_API_KEY="sk-..."
To use a different provider, set OPENAI_BASE_URL to the provider
endpoint and keep OPENAI_API_KEY pointing to the correct key:
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="your-provider-key"
Development
- Install the test dependencies:
pip install -e .[test]
- Run the test suite:
pytest
Use mkdocs serve to build the documentation locally.
License
This project is released under the MIT license. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygent-0.1.18.tar.gz.
File metadata
- Download URL: pygent-0.1.18.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f60931d500534cd6ec030a761b6408f9708bbb1abdd71132a7032936cba6e8c
|
|
| MD5 |
49f97e3d6c9c8fab7f2939b24f480bdb
|
|
| BLAKE2b-256 |
dd477e5fd9fdd8750fc33de7226aa2562794ef1352748034eb62dedb550a43ba
|
Provenance
The following attestation bundles were made for pygent-0.1.18.tar.gz:
Publisher:
ci.yml on MarianoChaves/pygent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygent-0.1.18.tar.gz -
Subject digest:
6f60931d500534cd6ec030a761b6408f9708bbb1abdd71132a7032936cba6e8c - Sigstore transparency entry: 256672030
- Sigstore integration time:
-
Permalink:
MarianoChaves/pygent@97be9c59cb66b3b751df19e9a6886c7c764a02a0 -
Branch / Tag:
refs/tags/v0.1.18 - Owner: https://github.com/MarianoChaves
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@97be9c59cb66b3b751df19e9a6886c7c764a02a0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygent-0.1.18-py3-none-any.whl.
File metadata
- Download URL: pygent-0.1.18-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b97a1297a728309ec7bcfed0b39a7613aac34f16bcf6b27527c4284335cf634
|
|
| MD5 |
d1b25b23ff70ad77e6d0525b05f0f1bb
|
|
| BLAKE2b-256 |
2d6ae8307548952d9e2ef38448a5d6c4a1f326658875aecc7094682a64b1eb6d
|
Provenance
The following attestation bundles were made for pygent-0.1.18-py3-none-any.whl:
Publisher:
ci.yml on MarianoChaves/pygent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygent-0.1.18-py3-none-any.whl -
Subject digest:
5b97a1297a728309ec7bcfed0b39a7613aac34f16bcf6b27527c4284335cf634 - Sigstore transparency entry: 256672040
- Sigstore integration time:
-
Permalink:
MarianoChaves/pygent@97be9c59cb66b3b751df19e9a6886c7c764a02a0 -
Branch / Tag:
refs/tags/v0.1.18 - Owner: https://github.com/MarianoChaves
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@97be9c59cb66b3b751df19e9a6886c7c764a02a0 -
Trigger Event:
push
-
Statement type: