Skip to content

Juspay Agentic Framework (JAF-PY)

A production-ready, purely functional framework for building robust and type-safe AI agents in Python.

Overview

JAF follows functional programming principles for predictable, testable AI systems:

  • Immutable State: All core data structures are deeply immutable
  • Pure Functions: Core logic is side-effect free and predictable
  • Type Safety: Leverages Python's type system with Pydantic
  • Effects at Edge: Side effects isolated in Provider modules

Quick Example

from jaf import Agent, function_tool

@function_tool
async def calculate(expression: str, context) -> str:
    """Perform safe arithmetic calculations.

    Args:
        expression: Math expression to evaluate (e.g., '2 + 3', '10 * 5')
    """
    allowed_chars = set('0123456789+-*/(). ')
    if not all(c in allowed_chars for c in expression):
        return 'Error: Invalid characters'
    try:
        result = eval(expression)
        return f'{expression} = {result}'
    except Exception:
        return 'Error: Invalid expression'

agent = Agent(
    name='MathAgent',
    instructions=lambda state: 'You are a helpful math assistant.',
    tools=[calculate]
)

Installation

pip install git+https://github.com/xynehq/jaf-py.git

Documentation