Docs

Optimization pattern guides

These are common issues Papaya finds in the workflows we test. Individual findings are tailored to a specific workflow, while these pages explain the broader pattern, impact, and common fixes.

Missing context

Give the model the context it needs before the decision point

The workflow begins making decisions before it has the customer, policy, state, or domain facts needed to stay grounded.

Unused context

Stop sending context that later steps do not use

Prompts carry large stable or retrieved context even though the next decision does not materially use it.

Oversized context

Trim large payloads before they enter reasoning steps

Raw tool, retrieval, or schema payloads flow into later prompts when the next step only needs a few fields.

Repeated prompt fragments

Reuse stable instructions instead of copying them into every call

The same system, policy, or formatting text is copied across many runs or stages instead of being reused once.

Clarification burden

Collect required inputs before starting the workflow

Users get follow-up questions only after the workflow has already spent tokens on reasoning or tool work.

Retry loops

Change strategy or stop instead of retrying the same failed path

A failed operation repeats without changing the inputs, constraints, or recovery strategy that caused the failure.

Truncation/resume churn

Persist compact state so resumed work does not rebuild context

Long-running workflows lose or rebuild important state after truncation, resume, or handoff points.

Tool misuse

Validate inputs before running expensive tools

Tools run before the workflow has enough context, permission, or constraints to use their results correctly.

Tool error loop

Handle repeated tool failures with a new path

The same tool error gets copied into the prompt and retried without a new recovery plan.

Composite tool opportunity

Bundle repeated low-level calls into one domain-level tool

Related records are fetched one at a time, leaving the model to assemble data that a domain tool could return directly.

Mutation safety

Validate state-changing actions before they execute

State-changing actions can execute without enough quote, dry-run, or validation evidence.

State delta grounding

Make requested changes and preserved state explicit

The workflow identifies the requested change but does not separately ground the fields that must remain unchanged.

Output contract mismatch

Make the final answer match the required contract

Useful content still fails the workflow when required fields, format, refusal behavior, or schema rules are missing.

Outcome cohort gap

Compare failing and passing runs before changing the workflow

Passing and failing runs diverge in behavior, but the workflow keeps routing them through the same path.

Evaluation coverage

Add enough labels before optimizing quality

The workflow lacks enough outcome labels or score coverage to know whether optimization changes are safe.

Model right-sizing

Use expensive models only where reasoning requires them

Broad reasoning models are being used for constrained extraction, routing, formatting, or classification work.

Delegated task overhead

Keep delegated work bounded and compact

Sub-agents isolate work, then send back long narrative payloads that the parent has to read and synthesize again.

Workflow ordering

Run validation and prerequisites before expensive branches

Steps run before their prerequisites are settled, creating rework or decisions based on incomplete state.

Template opportunity

Turn repeated successful paths into reusable templates

Many successful runs already follow the same shape, making the workflow a strong candidate for a shared template.

Missing verification gate

Add a final verification gate before packaging the answer

The workflow packages an answer without checking it against task, format, and safety requirements.

Retrieval strategy

Filter retrieval before it reaches the reasoning step

Retrieval brings back too many weak candidates, forcing later model calls to sort through irrelevant material.

Prompt caching reuse

Cache stable prompt content that repeats across runs

Large invariant context or instructions are sent repeatedly instead of using prompt caching or references.