OpenParable
Skip to content
← Back to skills

Python Agent Engine

Agent Building
python-agent-engine

Python Agent Engine is an Agent Skill for agent building published in the kennyzir/7deer_skills repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

A production-ready Python AI Agent engine using LangChain. Supports ReAct pattern, tool calling, and thinking process tracking.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/kennyzir/7deer_skills/blob/HEAD/python-agent-engine/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/python-agent-engine, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Python Agent Engine

A plug-and-play AI Agent core for Python applications. It handles the complexity of LLM interaction, tool calling loops, and context management.

Features

  • ReAct Loop: Automatically handles "Reasoning -> Tool Call -> Result -> Answer" process.
  • Thinking Process: Returns structured "Thinking Steps" for UI visualization.
  • Model Agnostic: Works with OpenAI, DeepSeek, or any OpenAI-compatible API.

Installation

  1. Copy resources/agent_engine.py to your project (e.g., src/core/agent_engine.py).
  2. Install dependencies:
    pip install langchain-core langchain-openai python-dotenv
    
  3. Set Environment Variables in your .env file:
    OPENAI_API_KEY=sk-...
    # Optional:
    OPENAI_BASE_URL=https://api.openai.com/v1
    

Usage Example

import asyncio
from langchain_core.tools import tool
from core.agent_engine import AgentEngine

# 1. Define Tools
@tool
def calculator(expression: str) -> str:
    """Calculates a math expression."""
    return str(eval(expression))

# 2. Initialize Agent
agent = AgentEngine(
    tools=[calculator],
    system_prompt="You are a helpful math assistant.",
    model_name="gpt-4o"
)

# 3. Chat
async def main():
    response = await agent.chat("What is 123 * 456?")
    
    print(f"Answer: {response.content}")
    print("\nThinking Steps:")
    for step in response.thinking_steps:
        print(f"[{step.type}] {step.content}")

if __name__ == "__main__":
    asyncio.run(main())