coding_agent_lib
A small Python library wrapping a LangGraph + Ollama coding agent. Instead of
the original interactive input() loop, you import it and call
agent.run(query) directly from your own code.
Install
pip install -e . --break-system-packages
This pulls in langgraph, langchain-ollama, and langchain-core.
You also need a running Ollama server with a model pulled locally, e.g.:
ollama pull qwen2.5-coder:7b
ollama serve
Usage
from coding_agent_lib import CodingAgent
agent = CodingAgent(model="qwen2.5-coder:7b") # base_url defaults to localhost:11434
# Generate new code -- the agent infers intent, task, and file path from
# your natural-language query.
result = agent.run(
"generate code for finding factorial of a number and save it to factorial.py"
)
if result.success:
print("Written to:", result.file_path)
print(result.code)
else:
print("Error:", result.error)
# Debug an existing file
result = agent.run("debug factorial.py, it crashes on negative input")
CodingAgent(model=None, base_url=None, temperature=0.0, workdir=None)
model— Ollama model name. Defaults to env varOLLAMA_MODELor"qwen2.5-coder:7b".base_url— Ollama server URL. Defaults to env varOLLAMA_BASE_URLor"http://localhost:11434".temperature— sampling temperature (default0, deterministic).workdir— if set, relative file paths extracted from queries are resolved against this directory instead of the current working directory.
agent.run(query: str) -> AgentResult
Runs a single request end-to-end (parse → generate/debug → save to disk) and
returns an AgentResult:
| Field | Type | Description |
|---|---|---|
success |
bool |
True if no error occurred |
query |
str |
The original query you passed in |
intent |
"generate" | "debug" | None |
What the agent decided to do |
task |
str | None |
Extracted coding task / debug instructions |
file_path |
str | None |
Resolved path the agent wrote to |
code |
str | None |
Final code written to the file |
original_code |
str | None |
Pre-fix code (debug mode only) |
error |
str | None |
Error message if success is False |
Notes
- The agent uses the LLM itself (not regex/keyword matching) to figure out intent, task, and file path from free-form queries.
- "debug" mode reads the existing file, asks the LLM to fix it, and overwrites the file with the corrected version.
- Each call to
run()is independent/stateless; call it repeatedly (in a loop, a web handler, a CLI, etc.) instead of using the old blockinginput()prompt.
Metadata
Release files for coding-agent-lib 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coding_agent_lib-0.1.0.tar.gz | 8.7 kB | Without provenance | Details for coding_agent_lib-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coding_agent_lib-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for coding_agent_lib-0.1.0-py3-none-any.whl |
Total release size: 17.7 kB
Release files / coding_agent_lib-0.1.0.tar.gz
| Download URL | coding_agent_lib-0.1.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51c8e795df1332dd8973f8f57edaf5e3135472fef17c2e92529393bd90be7043
|
|
BLAKE2b-256 checksum How to use checksums |
8aebac82da6e6a1a631b787af9801443a51d7377093a11c4a4d0ef61a8fb088e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / coding_agent_lib-0.1.0-py3-none-any.whl
| Download URL | coding_agent_lib-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca30a7ad0e991c8e90f6d84a6627ccd00d0eb05523bbb7b3739b46e693f1259e
|
|
BLAKE2b-256 checksum How to use checksums |
e434e4dbf2ce27a69a2f04252c6975dcf40d227f8d3f0bb09162003385614dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for coding-agent-lib 0.1.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.