Examples#

Every example below is a runnable Jupyter notebook committed to the repository under examples/.

Flagship screencast#

  • screencast/research_agent/screencast.ipynb — four-way head-to-head (create_react_agent baseline vs. hand-wired StateGraph vs. LangGOAP vs. LangGOAP-under-disruption) with real OpenAI + Tavily costs and Tavily-key revocation as the climax.

LangGraph tutorial refactors#

Official LangGraph tutorials rewritten as GOAP. Each notebook runs the condensed hand-wired original, the GOAP version and the GOAP version under disruption, hermetically, backed by an integration test.

  • screencast/llm_compiler/llm_compiler_screencast.ipynb — LLMCompiler: $N dependency references, a hand-written scheduler and a joiner that emits Replan become preconditions, executor="parallel" and the observer’s blacklist-and-replan loop.

  • screencast/email_assistant/email_assistant_screencast.ipynb — executive-ai-assistant: three message-shape routers with ValueError fall-throughs and four Agent Inbox handlers become triage facts as preconditions, require_human_approval=True and a Pydantic form; a denied send is re-planned around, and a new process resumes a paused thread.

  • screencast/weather_alert/weather_alert_screencast.ipynb — GenAI_Agents weather disaster management: a router with an unreachable branch, an input() approval node and a swallowed SMTP failure become a sensor’s facts as preconditions, require_human_approval=True on approve_alert, an ActionQos retry with an SMS fallback, and a stuck handler that relaxes the goal when the operator says no.

Basics#

Short primers — each notebook exercises a single mechanic.

  • plan_visualization.ipynb — Mermaid, DOT, ASCII, and Gantt renderers over an A* → CSP plan.

  • nl_goal_interpreter.ipynb — Plain-English request → GoalSpec via any BaseChatModel.

  • create_goap_agent_quickstart.ipynb — The Layer A one-liner: LangChain tools + goal → compiled StateGraph.

  • termination_policies.ipynb — MaxCostPolicy, MaxActionsPolicy, and FirstOfPolicy composition.

  • stuck_handlers.ipynb — FunctionalStuckHandler and MulticastStuckHandler recovering planning failures.

  • typed_form_hitl.ipynb — Typed-form interrupt() with Pydantic validation on resume.

  • action_qos.ipynb — In-executor retry with ActionQos and exponential backoff.

  • cli.ipynb — The langgoap CLI: plan, actions, explain, visualize, deploy-init.

  • goap_subgraph.ipynb — Embedding a GoapGraph as a node of a larger StateGraph with add_goap_subgraph.

  • tracing.ipynb — Observability hooks with LoggingTracer, LangSmithTracer, and MultiTracer.

  • stochastic_gridworld.ipynb — TransitionModel separating declared effects from sampled dynamics on FrozenLake-4x4.

  • mcts_vs_astar_stochastic.ipynb — When to use MCTSStrategy instead of A* on stochastic domains.

Tutorials#

Complete end-to-end walkthroughs across three tiers of complexity.

Tier 1 — Primers

  1. directory_handler.ipynb — GOAP basics on a file-system world state.

  2. robot_navigation.ipynb — A* primer on a linear graph.

  3. hungry_agent.ipynb — Natural-language goal + cost-driven action selection.

  4. from_routing_graphs_to_goap.ipynb — Hand-wired LangGraph routing graph rewritten as a GOAP plan that absorbs runtime disruptions.

Tier 2 — Workflows and constraint optimization

  1. cloud_balancing.ipynb — VM bin-packing with the create_goap_agent one-liner.

  2. vehicle_routing.ipynb — Capacity-constrained routing with CSP temporal scheduling.

  3. nurse_rostering.ipynb — Shift assignment with HardSoftScore and skill matching.

  4. project_job_scheduling.ipynb — RCPSP with precedence constraints and makespan minimization.

  5. task_assigning.ipynb — Ticket routing with the fluent ConstraintBuilder.

  6. sql_query_agent.ipynb — Schema-explore → generate → test → refine loop using effect_validator.

  7. vulnerability_scanner.ipynb — Phased discovery with action blacklisting.

  8. cost_bounded_research_agent.ipynb — Token / USD budget enforced via MaxCostPolicy.

  9. personal_shopper_agent.ipynb — Utility-maximizing planning with UtilityStrategy and NirvanaGoal.

  10. scheduled_delivery_confirmer.ipynb — Typed-form HITL with Pydantic validation.

  11. deepagents_integration.ipynb — Embed a GoapGraph as a StructuredTool or Deep Agents subagent.

Tier 3 — Full-stack showcases

  1. deep_research_agent.ipynb — LLM-heavy research loop with StoreExecutionHistory and tracing.

  2. hierarchical_product_launch.ipynb — MultiGoal sequential decomposition.

  3. content_builder_agent.ipynb — Multi-objective CSP with conditional format generation.

  4. temporal_match_cellar.ipynb — Durative actions with overlap constraints and parallel scheduling.

  5. flexible_job_shop.ipynb — Every v0.1.0 feature in one notebook.

  6. supply_chain_disruption_mediator.ipynb — Stuck handlers and goal relaxation under cascading disruption.

  7. code_review_agent_mcp_deployment.ipynb — langgoap deploy-init scaffolds a langgraph dev-ready deployment with an /mcp endpoint.