Query Tool

A read-only tool that retrieves data without side effects.

category: Tool
arcade.dev/patterns

Context

Building tools that fetch information.

Problem

Agents need to access data in order to make decisions, reason about a problem, and plan actions.

Solution

A Query Tool:
- Interacts with external systems: retrieves data from external systems (database, API, etc.)
- Never modifies state: guarantees idempotency by design
- Returns data: Structured response
- Cacheable: Results can be cached

Examples

Python
@tool(read_only=True)
def get_user_profile(user_id: str) -> UserProfile:
    """Retrieve user profile. Safe to retry."""
    return db.users.find_one(user_id)
TypeScript
const getUserProfile = tool({
  name: "get_user_profile",
  readOnly: true,  // Hint: no side effects
  execute: async ({ userId }) => db.users.findOne(userId)
});

Considerations

  • Mark read-only tools explicitly for agent optimization
  • Query tools can be parallelized safely
  • Consider caching for expensive queries

Related Patterns

More in Tool