Schema Sync
Prerequisites & Dependencies
- Access to external toolkit APIs (Composio, Canva, ClickHouse, etc.)
- Python 3.10+ (for schema diffing and HTTP requests)
- No external runtime dependencies beyond standard library (urllib, json)
Execution Steps
Identify workflow: Determine which multi-step toolkit workflow is about to execute (e.g., "create design from brand template", "generate presentation", "autofill design").
Ping live schema: Query the live tool for its current schema definition:
- For Composio: call
COMPOSIO_GET_TOOL_SCHEMAS with the toolkit slug
- For Canva: call
canva_get_brand_template_dataset with the template ID
- For ClickHouse: query information schema tables
- Capture the live schema's field names, types, required/optional flags
Diff against cached schema: Compare the live schema against my internally cached schema (last refreshed at schema-sync last-run):
- Added fields: New fields not in my cache → flag as
schema-updated
- Removed fields: Fields in my cache but not live → flag as
schema-deprecated
- Type changes: Type mismatches (string→number, etc.) → flag as
schema-broken
- Required flag changes: Optional→required or vice versa → flag as
schema-breaking
Rewrite workflow plan on mismatch: If any diff is detected (added, removed, type change, required-flag change):
- Halt the current workflow plan
- Regenerate the workflow using the live schema
- Surface a diff report to the user showing what changed
- Update my internal cached schema to the live version
No mismatch → proceed silently: If diff is empty, proceed with the existing workflow plan without user interruption.
Schema Diff Report Example
Schema Sync Report (Composio GMAIL)
==============================
Last synced: 2026-09-11T09:00:00Z
✅ Added fields (2):
- "reply_body" (string, optional)
- "thread_id" (string, required)
⚠️ Removed fields (1):
- "old_attachment_flag" (string, optional) — deprecated in v2 API
🔧 Type changes (1):
- "priority": was "low|medium|high" (string), now "1-5" (string) — non-breaking
❌ Required flag change:
- "to": was optional, now required — BREAKING; workflow regenerated
Action: Workflow plan regenerated using live schema. Cached schema updated.
Workflow Guard Example
Before schema-sync: I'd build a Canva design generation workflow using my cached schema, which might assume certain autofill fields exist. If Canva API changed those fields, my workflow would silently fail at runtime.
After schema-sync: Before each Canva workflow, I ping the live dataset schema, diff it, and either auto-update my plan or alert the user to the changes — never proceeding with stale assumptions.
Windows PowerShell Notes
- API ping via
Invoke-RestMethod with proper auth headers
- Schema diff comparison: use
Compare-Object PowerShell cmdlet
- Cached schema stored at
~\.opencode\schema-cache.json with UTC timestamp
- On mismatch, re-download and overwrite cache automatically
1---2name: schema-sync3description: Before multi-step toolkit workflows, pings the live tool (via schema-style endpoints / search tools) and diffs against my cached schema; on mismatch, rewrites the workflow plan, never the cached assumptions silently.4---56# Schema Sync78## Prerequisites & Dependencies910- Access to external toolkit APIs (Composio, Canva, ClickHouse, etc.)11- Python 3.10+ (for schema diffing and HTTP requests)12- No external runtime dependencies beyond standard library (urllib, json)1314## Execution Steps15161. **Identify workflow**: Determine which multi-step toolkit workflow is about to execute (e.g., "create design from brand template", "generate presentation", "autofill design").17182. **Ping live schema**: Query the live tool for its current schema definition:19 - For Composio: call `COMPOSIO_GET_TOOL_SCHEMAS` with the toolkit slug20 - For Canva: call `canva_get_brand_template_dataset` with the template ID21 - For ClickHouse: query information schema tables22 - Capture the live schema's field names, types, required/optional flags23243. **Diff against cached schema**: Compare the live schema against my internally cached schema (last refreshed at `schema-sync last-run`):25 - **Added fields**: New fields not in my cache → flag as `schema-updated`26 - **Removed fields**: Fields in my cache but not live → flag as `schema-deprecated`27 - **Type changes**: Type mismatches (string→number, etc.) → flag as `schema-broken`28 - **Required flag changes**: Optional→required or vice versa → flag as `schema-breaking`29304. **Rewrite workflow plan on mismatch**: If any diff is detected (added, removed, type change, required-flag change):31 - Halt the current workflow plan32 - Regenerate the workflow using the live schema33 - Surface a diff report to the user showing what changed34 - Update my internal cached schema to the live version35365. **No mismatch → proceed silently**: If diff is empty, proceed with the existing workflow plan without user interruption.3738## Schema Diff Report Example3940```41Schema Sync Report (Composio GMAIL)42==============================43Last synced: 2026-09-11T09:00:00Z4445✅ Added fields (2):46- "reply_body" (string, optional)47- "thread_id" (string, required)4849⚠️ Removed fields (1):50- "old_attachment_flag" (string, optional) — deprecated in v2 API5152🔧 Type changes (1):53- "priority": was "low|medium|high" (string), now "1-5" (string) — non-breaking5455❌ Required flag change:56- "to": was optional, now required — BREAKING; workflow regenerated5758Action: Workflow plan regenerated using live schema. Cached schema updated.59```6061## Workflow Guard Example6263**Before schema-sync**: I'd build a Canva design generation workflow using my cached schema, which might assume certain autofill fields exist. If Canva API changed those fields, my workflow would silently fail at runtime.6465**After schema-sync**: Before each Canva workflow, I ping the live dataset schema, diff it, and either auto-update my plan or alert the user to the changes — never proceeding with stale assumptions.6667## Windows PowerShell Notes6869- API ping via `Invoke-RestMethod` with proper auth headers70- Schema diff comparison: use `Compare-Object` PowerShell cmdlet71- Cached schema stored at `~\.opencode\schema-cache.json` with UTC timestamp72- On mismatch, re-download and overwrite cache automatically