Uncategorized - Tygart Media

Category: Uncategorized

  • Error Handling and Fallbacks in Notion AI Workflows

    Error Handling and Fallbacks in Notion AI Workflows

    Error Handling and Fallbacks in Notion AI Workflows

    The 60-second version

    The default failure mode of a Notion agent is “stop.” That’s almost never what you want in production. Robust workflows define what happens for each kind of failure: agent times out, Worker fails, external API is down, the schema mismatched, the credit pool emptied. Each needs a planned response — retry, fall back to manual, escalate to human, log and continue. Without explicit handling, “the agent stopped working” becomes a mystery debug session.

    Five failure modes and their handling

    1. Agent timeout (rare but exists). A 20-minute Custom Agent run that doesn’t complete. Handling: log the timeout, surface to the human owner, don’t auto-retry (likely to repeat the same problem).
    2. Worker timeout (more common). Worker hits 30-second limit. Handling: structured error return from the Worker; agent decides whether to retry, partial-result, or fail. Don’t silently re-invoke.
    3. External API failure. API down, rate limited, or returning errors. Handling: retry with exponential backoff (max 3 attempts), then fall back to “external system unavailable” path with human notification.
    4. Schema mismatch. Agent expected JSON shape A, Worker returned shape B. Handling: validate at the boundary, log the mismatch, fall back to a default response, alert human to fix the schema drift.
    5. Credit exhaustion. Workspace credit pool hits zero (post-May 4). Handling: this is hard — the agent stops mid-execution. Mitigation is preventative: monitor credit consumption, alert at 75% of monthly budget, top up before zero.

    Three practical patterns

    The retry-with-backoff pattern.
    First attempt fails → wait 1 second, retry. Second fails → wait 4 seconds, retry. Third fails → escalate to human. Don’t retry indefinitely.
    The fallback-output pattern.
    When the primary path fails, return a known-safe default with metadata indicating it’s a fallback. Downstream consumers can check the metadata and decide whether to use the fallback or alert.
    The human-escalation pattern.
    Define clear handoff criteria. When the agent can’t complete, who gets pinged, with what context, in what channel? “Pings someone eventually” is not a plan.

    Logging requirements

    Production agent workflows need three log streams:
    Action log: what the agent did and when
    Error log: what failed, with enough context to diagnose
    Decision log: when the agent chose between options, what it chose and why
    Without all three, debugging takes 10x longer than it should.

    Where this goes wrong

    1. Trusting the default failure behavior. “The agent stopped” is rarely the right response. Define explicit handling.
    2. Silent retries. Retries that don’t log produce mysterious “sometimes it works” behavior. Always log retry attempts.
    3. No credit monitoring. Hitting credit zero stops every agent in the workspace. Monitor consumption proactively.

    What to read next

    Workers in TypeScript, Multi-Agent Orchestration, Security Posture, ROI Math.

  • Notion AI API Endpoints for Database Views: A Developer’s Tour

    Notion AI API Endpoints for Database Views: A Developer’s Tour

    Notion AI API Endpoints for Database Views: A Developer’s Tour

    The 60-second version

    Until Notion 3.4 part 2, working with database views via the API meant fetching the underlying database and replicating view logic in code. The new endpoints give direct programmatic access to view configurations — query a view, apply its filters server-side, modify its display properties, all via the API. For developers building agents and integrations, this removes a significant friction point.

    What the new endpoints enable

    1. Query a view directly.
    Fetch the rows a specific view shows, with the view’s filters and sorts already applied. Previously, you fetched the database and re-implemented filtering in client code. Now the server does it.
    2. Read view configuration.
    Inspect what a view’s filters, sorts, and column selections are. Useful for agents that need to understand what a view represents.
    3. Modify view properties programmatically.
    Update filters, sorts, or display settings via API. Useful for dynamic views that adapt based on agent context.
    4. List views per database.
    Enumerate all views attached to a database. Helpful for agents that need to discover the right view to query.

    Three patterns this enables

    1. View-driven agent context.
    Instead of giving an agent the entire database and a complex prompt about filtering, point the agent at a pre-configured view. The view defines the context; the agent works with the filtered subset.
    2. Dynamic view modification.
    An agent that adjusts a view’s filter based on conversation. “Show me last week’s high-priority items” becomes a real query against a view, not a search across the whole database.
    3. View-as-API.
    Treat each view as a parameterized data endpoint. Builders can expose specific views to specific agents, controlling exactly what data the agent sees through the view definition.

    Practical implementation notes

    • Fetching views: Use the database fetch tool first to discover view URLs. View URLs include the view ID after ?v=.
    • Multi-source databases: Views may apply to a specific source.
    • Permissions: API access to views inherits the database’s permission model.

    Where this goes wrong

    1. Treating views as static. Views can be modified by users in the UI. Agents that cache view configurations get stale.
    2. Over-fetching. Querying a view is more efficient than fetching the database and filtering client-side. Migrate.
    3. Confusion between views and data sources. Multi-source databases have both. Don’t mix the API parameters.

    What to read next

    Workers + External APIs, Workers in TypeScript, MCP, Designing Database Schemas for Autofill.

  • Prompt Patterns That Work Inside Notion: What Generic Prompting Guides Miss

    Prompt Patterns That Work Inside Notion: What Generic Prompting Guides Miss

    Prompt Patterns That Work Inside Notion: What Generic Prompting Guides Miss

    The 60-second version

    Most prompting advice was written for ChatGPT. ChatGPT prompts treat the AI as a blank-context entity that needs everything explained. Notion AI is different — it knows your workspace, so the right prompt patterns reference workspace structure rather than recreate it. Generic “act as an expert and provide a detailed analysis” prompts work poorly. Specific “read the project page X, summarize against rubric Y, output in format Z” prompts work well.

    Five patterns that work in Notion specifically

    1. Reference workspace structure explicitly.
    “Read the [Project Name] page and the linked research database. Summarize key decisions in the format below.”
    Better than: “Summarize this project.”
    2. Pin sources by name.
    “Using only content from the Q3 Strategy database and the Customer Interviews page, identify themes.”
    Better than: “Identify themes from our research.”
    3. Specify output structure with examples.
    “Output as: [Decision], [Date], [Owner], [Status]. Example: ‘Switch CRM to HubSpot, 2026-03-15, Sarah, Approved’.”
    Better than: “Format as a table.”
    4. Constrain length per section.
    “Five sections, two sentences each, in active voice.”
    Better than: “Be concise.”
    5. Reference style guides as named sources.
    “Match the voice of the Tygart Media style guide page.”
    Better than: “Use a professional tone.”

    Three patterns that don’t work in Notion

    1. Role-play prompts. “Act as an expert McKinsey consultant” produces generic consultancy-speak. Notion AI doesn’t need persona priming; it needs context priming.
    2. Long preamble. “I am working on a project that involves…” is wasted tokens when the agent can read the project page directly.
    3. Hypothetical scenarios. Notion AI works on workspace reality. Hypothetical prompts pull the agent away from the actual data.

    The compound prompt pattern

    Effective complex prompts inside Notion stack three elements:
    Source pinning (which pages/databases)
    Task specification (what to do with the source)
    Output specification (format, length, sections)
    A good prompt reads like a small specification. A bad prompt reads like a conversation starter.

    Where this goes wrong

    1. Importing ChatGPT habits. Long preambles and role-play priming hurt Notion AI more than they help.
    2. Vague source references. “Our notes” is ambiguous; “the Customer Interviews database” is specific.
    3. Output ambiguity. “Summarize” produces variance. “Five-section summary, two sentences each” produces consistency.

    What to read next

    How Notion Skills Work, Building Your First Skill, Auto Model Selection, Editorial Surface Area.

  • The Security Posture of Notion Agents: What You’re Actually Granting Access To

    The Security Posture of Notion Agents: What You’re Actually Granting Access To

    The Security Posture of Notion Agents: What You’re Actually Granting Access To

    The 60-second version

    Agents are powerful access tokens. Treating them casually is a security mistake. The correct posture: scope agent access tightly, audit access logs monthly, treat connected user accounts as security-sensitive (not convenient), and build approval gates around destructive operations. Most “AI agent caused a problem” stories trace back to over-broad access, not malicious intent.

    What an agent can access

    Within Notion:
    – Every page the connected user can see
    – Every database the connected user can edit
    – Cross-workspace content if the user has multi-workspace access
    Through integrations (when connected):
    – Slack channels the user can see (including DMs in some configurations)
    – Email content if Mail integration is on
    – Calendar events including private ones
    – Google Drive content the user has access to
    Through Workers:
    – Outbound HTTP to any pre-approved domain
    – Can write to external systems via API calls

    Three security postures

    1. Permissive (avoid): Connect admin or executive accounts. Agents inherit broad access. High risk.
    2. Functional (default for most): Connect a dedicated integration account with role-based access scoped to the agent’s purpose.
    3. Restrictive (compliance-sensitive use cases): Per-task scoped accounts. Approval gates on every external action. Daily audit log review.
    For most operators, functional is right. For finance, legal, healthcare, or regulated industries, lean restrictive.

    Five practices that reduce risk

    1. Use dedicated integration accounts. Don’t connect the founder’s account. Create an “agent-ops” user with scoped access.
    2. Audit access logs monthly. Notion shows what the agent has read. Look at it. Anomalies show up fast if you check.
    3. Approval gates on destructive operations. Workers that delete, send, or charge should require human confirmation.
    4. Curate approved domains. Each new approved domain is new attack surface. Add deliberately.
    5. Review skill scope before deployment. A skill with access to “all databases” is too broad.

    Where this goes wrong

    1. The “connect everything” pattern. Agents with access to every database, every integration, every approved domain. Convenient to set up; high blast radius.
    2. Treating agent audit logs as theoretical. They exist for a reason. If you never look, you won’t catch the problem until it’s downstream.
    3. Letting agents act on opposing-party data. Agents writing to customer-facing systems autonomously needs much higher review.

    What to read next

    Workers + External APIs, MCP, AI-Native Company Patterns, Notion AI for Legal Ops.

  • Multi-Agent Orchestration in Notion: When One Agent Hands Off to Another

    Multi-Agent Orchestration in Notion: When One Agent Hands Off to Another

    Multi-Agent Orchestration in Notion: When One Agent Hands Off to Another

    The 60-second version

    Single mega-agents are tempting and bad. Specialized agents in a sequence with clear handoffs are harder to design but much more reliable. The principle: each agent does one thing well and hands a structured result to the next. Three handoffs is about the practical limit before debugging becomes painful. Beyond three, refactor.

    Three orchestration patterns that work

    1. The pipeline pattern.
    Agent A produces structured output → Agent B consumes and produces → Agent C consumes and produces final result. Each agent’s output schema matches the next agent’s input schema. Clear linear flow.
    2. The router pattern.
    A routing agent decides which specialist agent should handle the request, then dispatches. Specialists are scoped tightly to their domain. The router doesn’t do work itself; it just routes.
    3. The reviewer pattern.
    A producer agent generates output. A reviewer agent checks against criteria and either approves or returns specific feedback. Iterates until approved or max-attempts hit.

    Three patterns that fail

    1. Recursive agent chains. Agent A calls Agent B which calls Agent A again. Debugging is awful. Don’t.
    2. Shared mutable state. Two agents writing to the same database row simultaneously. Race conditions and overwrites. Don’t.
    3. Implicit handoffs. Agent A produces unstructured text; Agent B parses it. The first format change breaks everything. Use structured handoffs.

    Designing the handoff contract

    The handoff between agents is the highest-risk surface. Three rules:
    Define the schema explicitly. The output of Agent A is JSON-schema-validated input to Agent B.
    Version the schema. Schema changes are breaking changes. Version like APIs.
    Test the handoff in isolation. Mock Agent A’s output; test Agent B’s handling. Mock Agent B’s expected input; test Agent A’s production.

    Where orchestration goes wrong in production

    1. Cost compounds with depth. Each agent call consumes credits. A three-handoff workflow costs roughly 3x a single-agent workflow. Budget accordingly.
    2. Latency compounds too. A 5-second agent x 3 handoffs is 15 seconds end-to-end.
    3. Failure modes multiply. Agent A succeeds, Agent B fails, what happens? Define the failure handling explicitly.

    What to read next

    Workers for Agents in TypeScript, Building Your First Skill, Error Handling in Notion AI Workflows, Custom Agents vs Basic.

  • Workers for Agents in TypeScript: Patterns That Hold Up in Production

    Workers for Agents in TypeScript: Patterns That Hold Up in Production

    Workers for Agents in TypeScript: Patterns That Hold Up in Production

    The 60-second version

    Workers reward a specific style of TypeScript: small, single-purpose, structured-input-and-output, well-typed. The constraints (30 seconds, 128MB, no state) push you toward this style automatically. Workers that hold up in production share patterns: typed input/output schemas, defensive HTTP calls with timeouts, structured error returns, no hidden side effects.

    Five production patterns

    1. Type your input and output.
    Type strictly. The agent works against the schema. Schema drift breaks the agent silently.
    2. Defensive HTTP with timeouts.
    External API calls inside a 30-second budget need their own timeouts. A 25-second API call leaves 5 seconds for everything else. Set explicit fetch timeouts shorter than the Worker timeout.
    3. Structured error returns instead of throws.
    Throw inside a Worker and the agent gets opaque failure. Return structured error objects and the agent can reason about the failure and respond gracefully.
    4. Idempotency where state matters.
    Workers have no persistent state, but they can hit external systems that do. If the external call is non-idempotent (e.g., creates a record), include an idempotency key derived from input. Calling the Worker twice should produce one record, not two.
    5. Approved domains as a deployment artifact.
    Track domain approvals in code. When a Worker stops working in production, “did the approved domains change” is the first thing to check.

    Three production failures to design around

    1. The 30-second wall. Aim for under 5 seconds typical, under 15 worst case. Long calls fail under retry loads.
    2. Silent domain blocks. A Worker calling a non-approved domain fails with an error that isn’t always obvious. Log every outbound destination.
    3. Memory leaks via large responses. Don’t pull a 50MB JSON response into a 128MB Worker. Stream, paginate, or pre-filter at the source.

    Testing strategy

    Unit-test the Worker logic separately from the agent. Use mock HTTP. Then integration-test with the actual agent calling the Worker. The two test layers catch different bugs.

    What to read next

    Workers + External APIs, Notion AI Meets MCP, Workers for Agents foundation piece, Security Posture.

  • Designing a Database Schema for AI Autofill That Stays Trustworthy

    Designing a Database Schema for AI Autofill That Stays Trustworthy

    Designing a Database Schema for AI Autofill That Stays Trustworthy

    The 60-second version

    Most database schemas were designed for humans typing things in. Autofill works differently — it processes one row at a time using row content and a prompt. Schemas designed for Autofill make the prompt’s job easier and the human’s job auditable. Controlled vocabularies. Source attribution. Fill-date stamps. Clear separation between human and agent fields. Get the schema right and Autofill is reliable. Get it wrong and you’ll fight Autofill forever.

    Schema design principles

    1. Controlled vocabularies over free text. A “category” field with five select options outperforms a free-text field. Autofill picks from a list reliably; it improvises inconsistently.
    2. Atomic fields over compound fields. “Customer info” as a single text field is bad for Autofill. Separate fields (name, industry, size, region) each get filled cleanly.
    3. Source attribution columns. Add a “filled by” select (Human / Basic Autofill / Custom Agent) and a “fill date.” The audit trail makes drift visible.
    4. Separate human and agent fields. Don’t let Autofill overwrite human-entered fields. Configure Autofill to only fill empty cells or only specific columns marked for agent use.
    5. Validation columns where stakes are high. A “verified by human” checkbox on agent-filled fields creates a gate where human review happens before the field is trusted downstream.

    Patterns for specific use cases

    Content library: title (human), URL (human), summary (Autofill), category (Autofill from controlled list), tags (Autofill from controlled list), filled-by (auto), fill-date (auto), verified (human checkbox).
    CRM: company name (human), industry (Autofill from list), size (Autofill from list), key contacts (Autofill extraction), notes (human), last interaction (formula from related database).
    Research database: source (human), key claim (Autofill summary), category (Autofill), related projects (Autofill relation), my take (human), filled-by (auto).

    Three schema mistakes

    1. Letting Autofill manage relation properties. Cross-row relationships are judgment calls. Autofill misses context. Keep relations human.
    2. No fill date. Without a date stamp, you can’t tell stale data. After 30 days, Autofill output may not reflect current page state.
    3. Mixing free text with structured fields. A free-text “notes” field next to an Autofill “summary” creates confusion about which is canonical.

    What to read next

    AI Autofill Databases foundation piece, Editorial Surface Area, Second-Brain Architecture, Trust Gap.

  • Notion AI vs Zapier AI: Which Automation Layer Wins For Your Use Case

    Notion AI vs Zapier AI: Which Automation Layer Wins For Your Use Case

    Notion AI vs Zapier AI: Which Automation Layer Wins For Your Use Case

    The 60-second version

    Zapier and Notion AI overlap in concept (automate routine work) but optimize for different operators. Zapier: massive integration catalog, no-code, simple triggers and actions, optimized for “if this, then that” patterns. Notion AI: AI reasoning native, deep workspace context, optimized for “decide what to do given context, then act.” Use Zapier for breadth of simple automations. Use Notion Agents for depth of reasoning. The two are complementary.

    When Zapier wins

    • You need many simple automations across many apps
    • Non-technical operators need to build automations themselves
    • The trigger logic is straightforward (if X, do Y)
    • You don’t have or want AI reasoning in the loop
    • You’re not heavily invested in Notion as a platform

    When Notion Agents win

    • The workflow requires understanding Notion workspace content
    • AI reasoning about whether and how to act matters
    • Schedule-driven autonomous work is the goal
    • The workflow output is in Notion or affects Notion data
    • You want agents that can compose multi-step reasoning

    What Zapier does that Notion Agents don’t

    • Thousands of app integrations out of the box
    • Visual no-code building accessible to non-developers
    • Flat-rate pricing easier to budget
    • Established for years; lots of recipes and patterns

    What Notion Agents do that Zapier doesn’t

    • AI reasoning native to the workflow
    • Workspace context understanding
    • Skills (natural-language workflow definitions)
    • Workers for custom code
    • Database fluency at the platform level

    The combined pattern

    Many operators use both:
    – Zapier for cross-app plumbing (lead from form → CRM → Slack → email)
    – Notion Agents for workspace reasoning (synthesize lead context, decide priority, draft response)
    – Sometimes Zapier triggers a Notion agent run
    Treat them as layers: Zapier moves data; Notion Agents make decisions about that data.

    Where this goes wrong

    1. Trying to use Zapier for AI reasoning. Zapier has AI features but they’re shallow compared to Notion Agents.
    2. Trying to use Notion Agents for cross-app plumbing. Possible via Workers/MCP, but Zapier’s integration catalog is broader.
    3. Picking based on price alone. The right tool for the job costs less than the wrong tool, even at higher per-task pricing.

    What to read next

    Notion Agents vs n8n Alone, n8n MCP Bridge, Workers + External APIs, AI-Native Company Patterns.

  • Building Your First Notion Skill: A Step-By-Step Walkthrough

    Building Your First Notion Skill: A Step-By-Step Walkthrough

    Building Your First Notion Skill: A Step-By-Step Walkthrough

    The 60-second version

    Building a skill that works on the first try is rare. Building a skill that works after three iterations is normal. The discipline is starting with a narrow scope, writing specific instructions, testing against real inputs, and tightening based on what fails. Most operators build skills that are too broad and too vague. The fix is the opposite of intuition — narrower, more specific, more bounded.

    Step-by-step

    Step 1 — Pick the right first skill. Not the most ambitious one. The most repetitive one. “Weekly digest from project database” is a great first skill. “Generate our entire content strategy” is a terrible first skill.
    Step 2 — Write the instructions. Specific format. Specific sections. Specific length. Specific tone. “Summarize” produces variance; “Produce a one-page summary with these five sections in this order, max two sentences per section, in active voice” produces consistency.
    Step 3 — Bound the context. Which database does it read? Which pages? Which fields? Pin tightly. Expand only when needed.
    Step 4 — Test five times. Run the skill against five different real inputs. Look at outputs side by side. The variance you see is the variance you’ll get in production.
    Step 5 — Tighten based on failures. What was wrong in any output? Update the instructions to prevent that. Re-test. Loop.
    Step 6 — Document the skill. Note what it does, when to call it, and what its known failure modes are.

    Three patterns that fail

    1. The mega-skill. A skill that “drafts the weekly report including stakeholder updates and exec summary and content calendar.” Break it into three skills.
    2. The vague skill. “Help me write.” Define what kind of help, what kind of writing, in what format.
    3. The unbounded skill. No context boundaries. The agent reads everything and produces something that sounds related to nothing.

    Where this goes wrong

    1. Skipping the five-test step. Skills that work once fail differently. Test variance early.
    2. Treating skills as static. Skills need maintenance. When a database schema changes, the skill changes.
    3. Building too many skills too fast. Three great skills beat ten mediocre ones.

    What to read next

    How Notion Skills Work, Custom Agents vs Basic, Workers for Agents, Prompt Patterns That Work Inside Notion.

  • Notion Agents vs n8n Alone: When the Workflow Belongs Inside Notion

    Notion Agents vs n8n Alone: When the Workflow Belongs Inside Notion

    Notion Agents vs n8n Alone: When the Workflow Belongs Inside Notion

    The 60-second version

    This isn’t either-or. n8n is the deterministic workflow engine — when X happens, do Y across these 5 apps. Notion Agents are the reasoning layer — given the context, decide whether X actually warrants action and what the right action is. Combined via the n8n MCP bridge, they form a complete automation stack: agent reasons, n8n executes. Operators who treat them as competitors miss the leverage.

    When Notion Agents win

    • The workflow needs to read and synthesize Notion workspace content
    • Natural-language understanding of context matters
    • The “decide whether to act” question is the hard part
    • Schedule-driven autonomous work is the goal
    • The workflow output is itself in Notion

    When n8n wins

    • Pure cross-app data movement (no reasoning needed)
    • Hundreds of integration options matter
    • Visual workflow building with branching logic
    • High-volume deterministic automations
    • Workflows that don’t touch Notion at all

    The combined pattern

    The pattern that’s emerging:
    Notion Agent decides what to do based on context
    n8n workflow executes the cross-app coordination
    – Connected via the n8n MCP bridge inside Notion
    Example: Agent reads new lead in Notion → reasons whether it matches ICP → if yes, calls n8n workflow that updates Salesforce, sends Slack notification, schedules follow-up email.

    What n8n does that Notion Agents don’t

    • Massive integration catalog (Salesforce, Stripe, hundreds of others)
    • Visual flow building
    • High-throughput deterministic execution
    • Self-hosting option for compliance-sensitive use cases

    What Notion Agents do that n8n doesn’t

    • Natural-language understanding of unstructured workspace content
    • Native Notion database manipulation
    • Skills (saved natural-language workflows)
    • Workers for custom code execution
    • Schedule-driven autonomous reasoning

    Where this goes wrong

    1. Trying to do everything in one tool. Reasoning in n8n (limited) or deterministic execution in Notion Agents (expensive) is the wrong direction.
    2. Skipping the MCP bridge. Without it, you re-implement n8n integrations as Workers. Don’t.
    3. Letting agent reasoning replace simple n8n triggers. If the trigger is “row added to database,” that’s deterministic. Just use n8n.

    What to read next

    n8n MCP Bridge, Workers + External APIs, Notion AI vs Zapier, MCP foundation piece.