Julep Documentation

repository·main·Indexed 27 days ago

https://github.com/julep-ai/julep

Julep is a platform for building durable, composable AI agents using Python, leveraging Temporal for orchestration. It treats agent logic as dataflows (flows) that can safely crash, resume, and retry. The platform includes a CLI for managing agent graphs, a signed artifact-store bundle system for secure deployments without rebuilding Docker images, and support for various runtimes including Temporal, DBOS, and WASM.

Tokens
165.3K
Snippets
267
Records
899
Agent score
86%

What's inside julep

  1. Overview of mem-mcp Adoption Phase 3 and 4

    main

    The mem-mcp adoption plan is divided into two primary phases aimed at achieving agent-loop parity and production readiness:

    Phase 3: Agent-Loop Parity

    Focuses on making the Julep agent loop capable of running mem-mcp's tool-calling agents. Key features include:

    • Native provider tool-calling with parallel calls.
    • Tool-error observations (errors are treated as observations rather than causing run aborts).
    • Session turn survival during non-fatal errors.
    • require_tool_call enforcement.
    • Per-round dynamic context.
    • An evaluation runner that replays mem-mcp's 23 eval suites.

    Phase 4: Production Pre-conditions

    Focuses on closing critical production gaps:

    • Anthropic prompt caching.
    • Trajectory redaction.
    • Temporal replay-versioning discipline.
    • Cron/queue-lane primitives.
  2. Overview of the `ca` CLI

    main

    The ca CLI is a developer tool designed for composable-agents modules. It provides a unified interface to discover, inspect, run, gate, and observe agents.

    Key Capabilities:

    • Discovery: Automatically finds @flow and Agent(...) definitions in a module using a hybrid AST scan and subprocess resolver.
    • Inspection: Use commands like ls, show, and graph to inspect agent structures.
    • Execution: Run agents locally using the run command.
    • Gating: Use lint and test to validate agent code and logic.
    • Observation: Use trace and doctor to observe execution flows and debug issues.

    Technical Requirements:

    • Python ≥3.12
    • Requires the cli extra from the composable_agents package (installs typer).
  3. Overview of Julep

    main

    Julep is a framework designed for building agents as durable dataflows. Unlike ad-hoc loops, Julep flows are designed to crash and resume, retry safely, and provide explainability for every step through derived projections. It also enforces security by denying any tool the model was not explicitly granted.

    Key features include:

    • Define-by-construction: Use the @flow decorator to author agents.
    • Runtime Flexibility: The core is dependency-free, but you can opt into runtimes like Temporal, Kubernetes, or DBOS.
    • Durability: Built to handle interruptions and retries safely.
  4. Understand the Agent Loop as a Turn-based Model

    main

    Julep models the agent loop as a series of discrete 'turns' (Steps) rather than a single monolithic while True loop. This design reifies the agent loop's round body as a first-class endomorphism on AgentState.

    Key concepts:

    • The Turn Category: Focuses on endomorphisms of AgentState (the Writer-state containing last, trace, spent, and call_counts).
    • Step: A single round in the turn category. It is a callable that takes an AgentState and returns either a mutated AgentState (to continue) or a Halt (to terminate).
    • Halt: The terminal verdict of the loop, containing a status (e.g., "done", "escalated", "controller_error", "denied", or "over_budget"), an optional output, and a reason.
  5. Understand the Composable-agents CLI (`ca`) mental model

    main

    The ca CLI is a developer-facing tool designed for managing modules of @flow agents authored in Python. It operates on a "dbt for agents" model:

    • Module: A directory of @flow agents.
    • Nodes: Each agent is a node in a dependency graph.
    • Edges: Created by app or sub calls between agents.

    The CLI supports two primary development loops:

    1. Inner Loop (Local-first): Focused on rapid development using ca dev (hot-reload + in-memory backend), ca run (local execution), and ca chat (interactive REPL).
    2. Outer Loop (Deploy + Observe): Focused on production using ca deploy (pushing to Temporal/EKS), ca logs (tailing durable runs), and ca trace (inspecting runs with Langfuse deep links).

    ca acts as porcelain over existing composable-agents plumbing, orchestrating discovery, selection, and execution without re-implementing the core runtime.

  6. Core design principles of Typed Flow Calculus

    main

    The Typed Flow Calculus in Julep follows several key architectural decisions for composing agents and flows:

    • Typing Model: Uses hybrid typed edges. Leaves are typed, composition is checked, but Any is used at agent/LLM/JSON boundaries. Re-typing is opt-in.
    • Syntax: Uses a functional style with >> as the primary operator for composition.
    • Composition Patterns: Supports agent-as-node, flow-as-tool, and decompose-&-share.
    • Identity: Identity is derived and opt-in nameable. Naming is affine, meaning splitting a flow requires an explicit name.
    • Flow-as-tool: Capabilities are unified into a single list, lowering to APP.tools or APP.subflows.
    • Decomposition: Flows can be decomposed using with_, without_, or replace_.
    • Sub-agents: Implemented via the flow-as-tool pattern with attenuation.
    • Execution: The .run() method returns a Result[Out].
    • Validation: Construction is lazy and pure with cheap eager checks. Use .check() to force full validation. Full freeze-time gates are executed during .deploy() or .run().
    • Adapters: Explicit as_type or expect adapters must be used at Any boundaries to handle type transitions; these are not automatically inserted.
  7. Choose a Julep local execution mode

    main

    Julep offers several execution modes depending on your testing needs. Choose the smallest surface that matches your goal:

    ModeBest forServices required
    julep runFast source-level iteration from the CLINone
    prepare_local_pipeline(...).run/arunConfigured production-like foreground callsEffect dependencies only
    Deployment.dry_run(...)Unit tests with injected tools and reasonersNone
    TestClient(create_local_app(...))In-process control-plane and execution testsNone
    julep serve api --localInteractive API and client developmentNone
    julep dev upDurable single-machine acceptance testsPostgreSQL, Temporal CLI, worker effects

    Foreground vs. Durable Modes:

    • Foreground modes (the first five) return in the caller or API process, favor low latency, and omit crash recovery. Use these for unit tests, prompt iteration, and foreground request paths.
    • Durable mode (julep dev up) exercises release publication, API persistence, Temporal dispatch/replay, and release-scoped workers on a single machine.
  8. Run dotctx agents via AgentWorkflow

    main

    dotctx agents are integrated into the existing AgentWorkflow system. This allows agents to leverage a durable, bounded, and native tool-calling loop.

    Integration Details:

    • Mechanism: dotctx agents are lowered onto AgentWorkflow via a frozen alias map.
    • Capabilities: The underlying AgentWorkflow provides deterministic activity cids, contract-aware dispatch (concurrent READ calls, serialized writes), and the ability to require_tool_call or perform mid-loop continue-as-new operations.
  9. Use the julep CLI for agent management

    main

    julep is a developer CLI used to discover agents, select graph slices, and manage local or deployed sessions. It is typically run from the module root.

    Global Flags:

    • --version: Print the installed Julep package version.
    • --help: Print help information.
    • --install-completion: Install shell completion.
    • --show-completion: Print shell completion.

    Note on Configuration: Commands load configuration from the current directory (Path(".")). There is no --root flag; the CLI automatically looks for pyproject.toml (under [tool.julep]) or a sibling julep.toml.

  10. Understand the differences between Julep v1 and Julep 3

    main

    Julep 3 is a ground-up rewrite and is not an upgrade to Julep v1. They are fundamentally different products with different deployment models and APIs.

    Julep v1

    • Type: Hosted agents-API platform.
    • Model: A managed service with a REST API, sessions, memory, and tasks. You provision agents via API and Julep hosts and runs them for you.

    Julep 3

    • Type: Open-source, durable-agents framework.
    • Model: You install and run it yourself. You author agents as @flow dataflows in Python, which are compiled to a capability-bounded IR. These artifacts can be executed locally, on Temporal, or on DBOS.
    • Control Plane: Includes a self-hosted control plane. Running julep serve api exposes a bearer-authenticated /v1 API for releases, deployments, run submission, queries, and SSE. You are responsible for operating the API and the runtime.
  11. Understand the Julep Runtime Architecture

    main

    The Julep runtime operates across three distinct planes:

    1. Control Plane: Owns ordering and continuation. It uses a deterministic interpreter to walk the frozen JSON IR (either as a Temporal workflow or under an InMemoryEnv). Reasoners are ThinkStep leaves, and tools are CallStep leaves.
    2. Model & Tool Calls Plane: Handles all I/O, including LLM calls, MCP tools, and native HTTP tools. These are executed as activities through the Environment (Env).
    3. Projection Plane: A derived, append-only pomset view containing causal events, costs, spans, and gates. It is used for observability (OTel spans, replay UI, cost analysis) but is not used for durability or correctness; correctness and recovery must rely on the workflow history.
  12. Understand the Code-as-Data Worker Distribution Design

    main

    Julep is moving towards a 'code-as-data' model for flow deployments. Instead of building a new Docker image for every flow change, developers will publish content-addressed artifacts to a Content-Addressed Store (CAS).

    Key Concepts:

    • Flow-agnostic workers: Worker deployments are decoupled from flow changes. Workers are updated at the framework cadence, while flows are deployed by publishing data.
    • Artifact Identity: The artifact_hash is the primary identity, which hashes the entire envelope including flowJson, the bundle manifest, and pureRuntimeRefs (which includes source hashes, environment hashes, and execution tiers).
    • CAS (Content-Addressed Store): A storage backend (local-dir for dev/k3d or S3 for EKS) that stores immutable objects (flowJson, bundle manifests, env components) indexed by their SHA256 hash.
    • Immutability Rule: CAS objects are immutable and must not be deleted within the workflow-history retention period to ensure replay safety.