Skip to main content
This guide teaches you how to write goals that succeed on the first try. The examples are tested against real production traffic. The patterns work. Copy them, modify them, use them.
Quantified impact: In testing, specific goals completed 4.9x faster and returned 16x less unnecessary data compared to vague goals for the same task.
Before writing your first goal, read The Goal Parameter for the mental model — TinyFish Web Agent as a capable but literal-minded assistant that needs unambiguous instructions. This guide picks up from there with concrete, task-specific patterns.

Match Goal Style to Task Type

Different tasks benefit from different goal-writing approaches:

The Anatomy of a Great Goal

Every effective goal has up to seven components. Simple tasks may need only two or three. Complex extractions benefit from all seven.

The Transformation Pattern

Here’s how the same task looks at three quality levels:
The agent doesn’t know what “pricing” means to you. Annual vs monthly? Features included? What format?

Task-Specific Examples

For extraction, be specific and constrained to prevent over-fetching:

Single Runs vs. Batch Execution

Understanding when you’re running a single task versus scaling to many is critical for goal design.

Single Runs (Playground & Individual API Calls)

When you use this:
  • Testing and validating goals in the Playground
  • One-off extractions or automations
  • Prototyping before scaling
Goal design principles:
  • Focus on completeness—you want rich results from this one run
  • Include detailed edge case handling since you can iterate
  • Add verbose output instructions for debugging

Batch Execution (Projects & Concurrent API Calls)

When you use this:
  • Processing hundreds or thousands of URLs
  • Scheduled monitoring jobs
  • Building datasets at scale
Goal design principles:
  • Optimize for consistency—every run should return identical structure
  • Minimize fields to only what you need
  • Use strict schemas for reliable downstream processing

Schema Enforcement for Batch Runs

When running the same goal repeatedly, schema consistency is critical. Without explicit enforcement, the agent may return slightly different field names across runs. Best practice: Provide an example schema with exact field names AND sample values.
Why sample values matter:
  • Field names alone can be ambiguous (price vs "price": "29.99" vs "price": 29.99)
  • Sample values clarify expected types (number vs string, boolean vs “yes/no”)
  • The agent mirrors the pattern it sees
Anti-pattern: Return as JSON with product name, price, and availability.This might return {"name": "..."} one time and {"product_name": "..."} another.

Goal Writing Tips

Tell TinyFish Web Agent how to structure the response:
Anticipate what might go wrong:
For multi-step workflows, number the steps:
When data from one step is needed later, tell the agent to remember it:
Other phrases that work:
  • “Remember these values—you’ll need them for verification”
  • “Note the confirmation number displayed”
  • “Save this for later”
When element IDs aren’t known, describe visually:
Instead of:
Limit scope to avoid over-extraction:
Tell the agent when to stop:
When a page might have multiple layouts:

The Intern Test

Ask yourself: If I handed this goal to a smart but literal-minded intern who has never seen this website, would they:
  • Know exactly where to look first?
  • Know when to stop?
  • Know what to do if something unexpected happens?
  • Know the exact format I want the answer in?
If any answer is “they would have to guess,” add more detail.

Ready-to-Use Templates

Copy and modify these templates for your use cases.

Troubleshooting

Common issues and how to fix them:
Runs have a 20-minute timeout (sync /run stops after 10 minutes; use /run-async for longer tasks). Design goals to complete their core task well within that limit. For complex multi-step workflows, break them into smaller runs.

Observed Behaviors

TinyFish Web Agent handles common natural language variations automatically:
Letter-based phone numbers like 555-WORK-123 may be converted to keypad digits (555-967-5123).

Known Limitations

The Goal Parameter

The mental model this guide builds on

TinyAgent Reference

Full request and response schema

Examples

Real-world code examples

FAQ

Common questions answered