Commit Graph

3 Commits

Author SHA1 Message Date
Ran Shem Tov f13f8865a8 feat(sdk-js/langgraph): zodState helper for agent state schemas
Add a zodState() helper that attaches a lazy `~standard.jsonSchema.input`
to a zod schema so LangGraph's StateSchema.getJsonSchema() emits the
field into the graph's output_schema. Without it, zod v4 fields carry
`~standard.validate` + `vendor` only, `isStandardJSONSchema` returns
false, and the field is silently dropped from output_schema — which in
turn causes the AG-UI LangGraphAgent proxy to filter the value out of
STATE_SNAPSHOT events on the wire, so the frontend never sees it even
though the underlying thread state has the data.

Apply zodState to the middleware's own `copilotkit` state field so it
surfaces in output_schema and export it for demos to use on custom
state fields (todos, documents, etc.).

Uses `z.toJSONSchema` when available (zod v4 subpath) and falls back to
an empty object, which is sufficient to make langgraph-api include the
key in output_schema.
2026-05-01 12:31:04 +02:00
Ran Shem Tov 09501b43ed chore(integrations/_parity): inline-prompt contract + track Dockerfile
Two small changes to the parity tooling, surfaced while validating it on
the langgraph-fastapi port.

1. Drop the per-instance PROMPT.md file. The reference demo
   (langgraph-python) does not load agent/PROMPT.md at runtime — it inlines
   the prompt as a triple-string literal in agent/main.py. Syncing a
   cosmetic PROMPT.md file to every instance created a contract the code
   did not follow. Now:
   - sync.ts no longer writes agent/PROMPT.md per instance.
   - verify.ts greps the first non-blank line of _parity/canonical/PROMPT.md
     against each instance's agent source. Inline the prompt string in
     source; verifier passes.
   - Deleted the now-orphaned PROMPT.md copy under langgraph-js/agent/.

2. Track Dockerfile, docker/Dockerfile.agent, and serve.py in the shared
   verbatim-files list. These were previously silent "allowed divergence"
   across all instances — any Docker or runtime-adapter drift shipped
   unflagged. Now:
   - Added to tracked.verbatimFiles in manifest.json.
   - langgraph-js keeps them in allowedDivergence (Node-only stack, legit
     difference from the Python-based reference).
   - langgraph-fastapi drops them from allowedDivergence (same language
     stack as the reference; Docker/serve.py should match).

README and the copilotkit-demo-parity skill updated to match the new
prompt contract. Verifier still supports `--target` and exits non-zero on
unexpected drift.
2026-05-01 12:31:04 +02:00
Ran Shem Tov 2bb9f3fdf4 chore(integrations): add _parity tooling + copilotkit-demo-parity skill
Introduce machinery for keeping examples/integrations/* demos aligned to a
single north-star (langgraph-python). Built first so the upcoming
langgraph-js and langgraph-fastapi alignment PRs have a mechanical baseline
to work against instead of manual copy-paste.

- examples/integrations/_parity/manifest.json declares verbatim files,
  tracked package.json keys, and expected agent surface (tool names,
  state keys) per instance plus allowed-divergence lists.
- _parity/sync.ts copies verbatim files + rewrites tracked package.json
  keys from north-star to a target instance. Dry-run supported.
- _parity/verify.ts diffs each instance vs north-star and exits non-zero
  on unexpected drift. Checks verbatim content, tracked keys, canonical
  prompt equality, and agent-surface grep-level presence.
- Canonical prompt at _parity/canonical/PROMPT.md — synced into each
  instance's agent/PROMPT.md on parity:sync.
- Root package.json: pnpm parity:sync, parity:verify, parity:check.
- CI: .github/workflows/integrations_parity.yml runs parity:check on PRs
  touching examples/integrations/**.
- Skill: .claude/skills/copilotkit-demo-parity/SKILL.md teaches agents
  how to drive sync/verify and handle manual-merge zones (agent code,
  api route, Dockerfile).

Does NOT touch the existing instance demos yet. Those alignment commits
follow in the same PR.
2026-05-01 12:31:04 +02:00