Skip to main content

A production-grade, type-safe Python Agent framework

Project description

Nonoka

A production-grade, type-safe Python agent framework with deterministic orchestration, conversational execution, and first-class MCP integration.

Features

  • Type-safe core — Pydantic-validated schemas throughout; agents, tools, and plans are all strongly typed
  • Deterministic orchestrationPlan + Step + ref() for explicit control flow, not just prompt-and-pray
  • Conversational executionReActAgent, ReflectiveAgent, and PlanExecutor paradigms out of the box
  • First-class tools@tool decorator with automatic Pydantic schema generation
  • Prompt engineering@prompt decorator and PromptTemplate for composable, type-safe prompt construction
  • MCP ready — built-in MCP (Model Context Protocol) support via mcp
  • Resilient execution — structured error taxonomy (TransientError, LogicError, SafetyError, etc.) with configurable RetryPolicy
  • Observable hooksHooks system for tracing, logging, and custom middleware
  • Multi-backend LLM — powered by litellm, supporting OpenAI, Anthropic, DeepSeek, and 100+ providers

Installation

pip install nonoka

Or with uv:

uv add nonoka

Quick Start

import asyncio
import nonoka

@nonoka.tool
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    return f"Sunny in {city}!"

async def main():
    agent = nonoka.Agent(
        name="weather-bot",
        tools=[get_weather],
    )
    result = await agent.run("What's the weather in Tokyo?")
    print(result.output)

asyncio.run(main())

Plans & Orchestration

Explicit multi-step workflows with type-safe references:

from nonoka import PlanBuilder, ref

plan = (
    PlanBuilder()
    .add_step("research", "Search for information")
    .add_step("summarize", "Summarize findings", depends_on=[ref("research")])
    .build()
)

executor = nonoka.PlanExecutor(plan=plan)
result = await executor.run("Latest AI breakthroughs")

Prompt Templates

Composable, type-safe prompts:

from nonoka import prompt, PromptTemplate

@prompt
def translate(text: str, target: str = "Chinese") -> str:
    """Translate the following text to {target}:

    {text}
    """

# Or programmatically
tpl = PromptTemplate("Summarize this in {style}:\n{content}")
output = tpl.render(style="bullet points", content=long_text)

ReAct Agent

agent = nonoka.ReActAgent(tools=[search, calculator])
result = await agent.run("What is 42 * the current temperature in Paris?")

Configuration

Nonoka supports three ways to configure agents: declarative files (YAML/JSON/TOML), fluent builders, and direct code.

Declarative Config (YAML)

Write a nonoka.yaml and load it:

# nonoka.yaml
agents:
  weather_assistant:
    model: gpt-4o
    system_prompt: "You are a weather assistant."
    max_turns: 10
    tools:
      - import: my_tools.weather:get_weather

  code_assistant:
    model: deepseek-chat
    system_prompt: "You are a coding assistant."

runner:
  checkpoint: memory
  memory: in_memory

defaults:
  model: deepseek-chat
  max_turns: 10
from nonoka import Config

config = Config.load("nonoka.yaml")           # or Config.auto_find()
agent = config.agents["weather_assistant"].build()
runner = config.runner.build()

Single-agent shorthand (no agents: dict needed):

agent:
  model: gpt-4o
  system_prompt: "You are helpful."
agent = config.agent.build()

Environment Variables in Config

Use ${VAR} or ${VAR:-default} in YAML values:

agent:
  model: ${NONOKA_MODEL:-gpt-4o}
  system_prompt: ${NONOKA_PROMPT}

Fluent Builder API

from nonoka import AgentBuilder, tool

@tool
async def get_weather(city: str) -> str:
    return f"Sunny in {city}!"

agent = (
    AgentBuilder()
    .model("gpt-4o")
    .system_prompt("You are a weather assistant.")
    .tool(get_weather)
    .tool_by_import("my_tools.search:search_city")
    .max_turns(20)
    .retry(max_retries=5, backoff=1.5)
    .metadata(category="weather")
    .tag("production")
    .build()
)

From Dict / YAML / JSON

from nonoka import Agent

# From dict
agent = Agent.from_dict({
    "model": "gpt-4o",
    "tools": ["my_tools:get_weather"],
})

# From file
agent = Agent.from_yaml("agent.yaml")
agent = Agent.from_json("agent.json")

Environment-driven Settings

Nonoka also integrates with pydantic-settings for framework-level config:

from nonoka.core.config import settings

print(settings.default_model)   # from NONOKA_DEFAULT_MODEL env var
print(settings.openai_api_key)  # from NONOKA_OPENAI_API_KEY env var

Requirements

  • Python >= 3.10

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonoka-1.1.1.tar.gz (73.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonoka-1.1.1-py3-none-any.whl (67.3 kB view details)

Uploaded Python 3

File details

Details for the file nonoka-1.1.1.tar.gz.

File metadata

  • Download URL: nonoka-1.1.1.tar.gz
  • Upload date:
  • Size: 73.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for nonoka-1.1.1.tar.gz
Algorithm Hash digest
SHA256 207b98405417be06c836ef3e18fb0ffce8c88270f6c2efb00e32ea73312e655f
MD5 cf88d8b81ce55ae73b3faf1be48b0a52
BLAKE2b-256 104f2e2124ff162b6b17145f9274fbf53231ddd0c24fe2be35c6be7c83a66078

See more details on using hashes here.

File details

Details for the file nonoka-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: nonoka-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 67.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for nonoka-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca0ede980ef130b488f780590b9df7e57390aafa676feeadb3611f4b6b672bb4
MD5 add5bd7f31f1844249026c8347562070
BLAKE2b-256 1d0a42bfa7594d5beec8a4c20e195410452350199336ce736cdcfb92dadc83c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page