Repository navigation
docs(examples): LangGraph tutorial refactors as GOAP screencasts - #83
Merged
Merged
Conversation
…rafter policy The version moved to langgoap/_version.py with ``dynamic = ["version"]`` (#44), but release.yml and test-release.yml still read ``[project].version`` from pyproject.toml, so the first job of a release would fail with KeyError. Both now parse the version file; the mismatch hint names the right file. Release Drafter: the autolabeler only sees pull-request events, so the workflow also runs on pull_request_target; a breaking change bumps the minor version while the project is pre-1.0 (it resolved to major, which would have drafted v1.0.0); docs PRs get their own category instead of landing uncategorised.
…dd_goap_subgraph (#19) The 0.2.0 notes say every on-ramp rejects an unknown compile keyword with a TypeError naming the compile options and the GoapGraph options, but only create_goap_agent did; GoapSubgraph.compile and add_goap_subgraph forwarded the kwargs raw and surfaced Python's generic message. The check now lives in integrations/_compile_options.py and all three call it; prebuilt re-exports the names for existing importers.
Bump __version__ to 0.2.0 and date the CHANGELOG entry. The entry opens with a "Breaking changes" summary (JSON-native state, the strict defaults, termination and reporting changes) and gains a "Removed" section for LangGOAPRedisSerializer; the Deprecated section no longer claims that LANGGOAP_ALLOWED_MSGPACK_TYPES warns on access, which a module constant cannot do. Stale "v0.1.0" wording in an error message and three docstrings, the Jupyter image's minimum version and the bug template placeholder are updated. tests/test_release_pipeline.py pins the release mechanics: the workflows read the version file, the version file matches the top CHANGELOG entry, a dated release with breaking changes says so, the Jupyter image installs the current minor, no package text names a stale release, and the release drafter follows the pre-1.0 policy.
A can_rerun=False action that already ran is blacklisted like a failed one, so the no_plan explanation told users to raise max_retries or attach an ActionQos "for transient failures" when nothing had failed; the personal-shopper NirvanaGoal run ended with exactly that advice. The suggestion now separates actions blacklisted after failures from spent ones (listed under spent_actions) and gives each its own advice, noting that a NirvanaGoal run ends this way by design. The log line no longer credits A* for every planning failure.
…ult budget to 8 (#12) Reading the re-executed tutorial outputs showed the objective-driven selection of #12 could not reach plans two swaps away: alternatives were produced by excluding one action of the A* plan at a time, so at most len(plan) candidates existed whatever max_alternatives said. With uniform action costs the cloud-balancing objective settled on a $1,506 placement while a feasible $1,092 one existed, and the project-scheduling soft budget of $20 looked unattainable although a two-swap plan meets it exactly. enumerate_alternatives now widens breadth-first over exclusion sets (one swap away, then two, ...) and deduplicates by action sequence; max_alternatives bounds how far it reaches and its default rises from 5 to 8. The job-shop tutorial constants and tests follow the plan the wider search selects ($120, two standard prepares, 7 h makespan) and also pin the limits honestly: the all-standard $57 minimum lies six swaps away and is reached by widening the budget to 63 or by encoding cost_usd as the A* cost. The CHANGELOG and concepts page describe the bounded neighbourhood.
…and correct their narratives Twenty notebooks were re-executed against main: the objective tutorials (cloud balancing, nurse rostering, task assigning, vehicle routing, temporal match cellar, project scheduling, flexible job shop, content builder), the sequential MultiGoal launch, the NirvanaGoal shopper, and the partially executed primers and comparisons. Every output cell was read against its prose. Narratives that the 0.2.0 defaults made false are corrected: infeasible plans are reported and not executed by default (GoalPolicy(on_infeasible="execute") opts in), objectives compare the A* plan against alternatives enumerated breadth-first within max_alternatives rather than "picking the cheapest", the job-shop and project-scheduling tables show the plans the wider search selects, the shopper explains that no_plan is the normal end of a NirvanaGoal run, and the remaining "v0.1.0" wording is version-neutral. The job-shop notebook gains a section showing that the $57 global minimum lies beyond the default budget and how to reach it.
Adds examples/screencast/llm_compiler/ with a condensed hermetic before.py ($N dependency resolver, thread-pool scheduler, Replan via SystemMessage), after.py (dependencies as preconditions, executor="parallel"), after_disrupted.py (index down for one city, for every city, and with the archive down too), a generated and executed notebook rendered in the docs, and an integration test that pins the wave count, the answer, the replan behaviour and the async path.
Adds examples/screencast/email_assistant/ with a condensed hermetic before.py (the upstream routers with their ValueError fall-throughs, one Agent Inbox round trip, the bad_tool_name patch loop, a scripted drafter), after.py (a triage sensor, seven actions whose preconditions carry the paths, require_human_approval=True on send_email and a Pydantic form on send_cal_invite), after_disrupted.py (a denied send and an invalid form are blacklisted and re-planned to escalate_to_user; a new process resumes a paused thread), a generated and executed notebook rendered in the docs, and an integration test covering the four paths, both gate payloads, the disruptions, crash-resume and the async path.
…GOAP screencast Adds examples/screencast/weather_alert/ with a condensed hermetic before.py (the upstream nodes and both routers verbatim, unreachable literal included; the input() approval node; the swallowed SMTP failure), after.py (a sensor grades the forecast once, eight actions whose preconditions carry the departments, require_human_approval=True on approve_alert, an ActionQos retry on send_email_alert with send_sms_alert as the dearer fallback, and a FunctionalStuckHandler that relaxes the goal to decision_logged when the operator denies the alert), after_disrupted.py (denial, a dropped SMTP connection, a dead relay), a generated and executed notebook rendered in the docs, and an integration test covering the four paths, the gate payload, the denial-and-relax path, both relay failures, the async path and the upstream behaviours the hand-wired version keeps.
✅ Code Quality Report
Quality Gates
🎉 All quality gates passed! This PR maintains high code quality standards. 📊 View detailed MFCQI breakdownRun |
A resume payload rejected by the Pydantic model (or of the wrong shape) was
recorded as a human_form_invalid failure with the count pre-set past
max_retries, so a typo blacklisted the action and, with no alternative,
ended the run in no_plan. It is an input error, not a decision: the gate
now raises the interrupt again with attempt, validation_errors and
rejected_payload in the payload. A form can be declined explicitly with
False or {"approved": False, "reason": ...}, recorded and blacklisted like
a denied boolean gate; the form gate had no way to say no before.
LangGraph returns only the channels a run wrote to, so result["blacklisted_actions"] and result["action_failure_counts"] raised KeyError precisely when nothing had gone wrong. The defaults now live in one table, STATE_DEFAULTS: GoapGraph.initial_state seeds them, the planner fills any that a hand-built input left out, and rehydrate_state fills them on the way out.
…e email screencast An invalid invite form is now asked again with the validation errors in the payload, and declining it is blacklisted like a denied send; the disruption script, notebook, README and test follow. Both disruption scripts index blacklisted_actions and replan_count directly now that every result carries them.
A boolean gate asks a yes/no question, but any non-empty string, non-zero
number, dict without approved or with a non-boolean approved counted as
approval, so Command(resume="no") approved the action. Only True / False
and {"approved": <bool>, "reason": ...} are decisions now; anything else
re-raises the interrupt with attempt, validation_errors and
rejected_payload, exactly like the typed-form gate. Both gate payloads
carry attempt and effects. _is_approved is replaced by
_approval_decision, which returns approved / denied / invalid.
GoalSpec.conditions, SoftGoal.conditions and GoalSpec.objectives were
annotated as MappingProxyType although every caller passes a dict and
__post_init__ converts it, so GoalSpec(conditions={...}) was a mypy error
in user code. The fields are annotated as Mapping (what a caller writes)
and still converted to an immutable MappingProxyType at construction.
…nt failure When every remaining path to the goal needs an action a human declined, the no-plan explanation advised raising max_retries or attaching an ActionQos for transient failures. It now lists the action under denied_actions with the operator's reason and points at what applies: an alternative action, a stuck handler that relaxes the goal, or running again once the decision changes.
# Conflicts: # CHANGELOG.md
The denial in the weather screencast is now explained as a denial, and the planner's no-plan log line no longer attributes the failure to A*.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three LangGraph tutorials rewritten as GOAP, each as a before / after / after-disrupted screencast with a generated, executed notebook and an integration test. Everything is hermetic (no API keys).
$Ndependency parser, thread-pool scheduler, joiner emittingReplanas aSystemMessage, routing onisinstance(messages[-1], AIMessage),recursion_limitexecutor="parallel"(3 executor invocations vs 4 sequential), observer blacklist-and-replan,no_planwith an explanationroute_after_triage/take_action/enter_after_humanwithraise ValueErrorfall-throughs, four Agent Inbox handlers,bad_tool_namepatch looprequire_human_approval=Trueonsend_email, a Pydantic form onsend_cal_invite; a denied send or declined form is blacklisted and re-planned toescalate_to_user; an invalid form is asked again with the errors; a new process resumes a paused threadroute_responsewith an unreachable"send_email_alert"literal,input()approval node that auto-approves anything not low/medium, swallowed SMTP failureapprove_alertgate,ActionQosretry + SMS fallback,FunctionalStuckHandlerrelaxing the goal on denialEach
before.pyis a condensed version of the upstream control flow and is itself tested so the contrast stays faithful (theValueError, the dead literal, the auto-approval of"Assessment Failed", the swallowed SMTP error are all reproduced).Notebooks are built by
_build_notebook.pyfrom the scripts (so they cannot drift), executed with nbconvert, and registered indocs/copy_notebooks.py/docs/examples/index.mdunder a new "LangGraph tutorial refactors" section. Output cells were read against the narrative.Four least-surprise defects surfaced while writing these and are fixed in #84 (typed forms that fail validation are asked again with the errors and can be declined explicitly; the boolean gate asks again instead of reading
"no"as approval; every bookkeeping key is present in every result;GoalSpec(conditions={...})type-checks). A fifth, the no-plan explanation calling an operator's denial a transient failure, is fixed on #82. This branch carries both #84 and #82 via merges so the notebooks show the corrected behaviour and CI runs against it; the three notebooks were re-executed on the merged code. Merge order: #84 → #82 → #83.No library code changes beyond the #84 and #82 commits it carries.
make check-equivalent run locally: 2119 passed (the two local failures are the staleimportlib.metadataversion of a 0.2.0 editable install against this branch's 0.1.2, and a benchmark test that--ignore=tests/benchmarksexcludes by default).