> ## Documentation Index
> Fetch the complete documentation index at: https://docs.relace.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Fast Agentic Search

> Run fast agentic search on a Relace Repo

## Path Parameters

<ParamField path="repo_id" type="string" required>
  Repo ID
</ParamField>

## Request Body

<ParamField body="agent_inputs" type="object" required>
  Input parameters for the agent

  <Expandable title="properties" defaultOpen={false}>
    <ParamField body="query" type="string" required>
      The query or question to process with the agent
    </ParamField>
  </Expandable>
</ParamField>

## Response

The agent returns a Server-Sent Events (SSE) stream with real-time updates as parallel tool calls execute.

### Event Types

<ResponseField name="started" type="event">
  Signals that the agent execution has begun

  <Expandable title="properties" defaultOpen={false}>
    <ResponseField name="prompt_id" type="string">
      Unique identifier for this agent execution session
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="agent" type="event">
  Contains agent reasoning, analysis, and text responses

  <Expandable title="properties" defaultOpen={false}>
    <ResponseField name="name" type="string">
      Name of the agent ("relace-search")
    </ResponseField>

    <ResponseField name="content" type="string">
      The agent's response content, reasoning, or analysis
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="tool" type="event">
  Reports tool usage and execution results. Tools can include file operations, bash commands, directory views, and specialized operations like `report_back`.

  <Expandable title="properties" defaultOpen={false}>
    <ResponseField name="name" type="string">
      Name of the tool being used (e.g., "view\_directory", "bash", "view\_file", "report\_back")
    </ResponseField>

    <ResponseField name="path" type="string">
      File or directory path (for file/directory operations)
    </ResponseField>

    <ResponseField name="command" type="string">
      Shell command being executed (for bash tool)
    </ResponseField>

    <ResponseField name="explanation" type="string">
      Detailed explanation of findings (for report\_back tool)
    </ResponseField>

    <ResponseField name="files" type="object">
      Map of file paths to line ranges referenced in the explanation (for report\_back tool)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="done" type="event">
  Signals that the agent execution has completed successfully
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/agent \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "agent_name": "relace-search",
      "agent_inputs": {
        "query": "Where in the project are global styles and UI components defined?"
      },
      "continue": false
    }'

  ```

  ```TypeScript TypeScript SDK theme={null}
  import { Relace } from "@relace-ai/relace";

  const client = new Relace({ apiKey: "YOUR_API_KEY" });

  const repoId = "123e4567-e89b-12d3-a456-426614174000";
  const results = client.repo.search(repoId, {
    query: "Where in the project are global styles and UI components defined?",
  });

  for await (const event of results) {
    console.log(event);
  }
  ```

  ```Python Python SDK theme={null}
  from relace import Relace

  client = Relace(api_key="YOUR_API_KEY")

  repo_id = "123e4567-e89b-12d3-a456-426614174000"
  results = client.repo.search(repo_id, query="Where in the project are global styles and UI components defined?")
  for event in results:
      print(event)
  ```
</RequestExample>

<ResponseExample>
  ```text SSE Stream theme={null}
  event: started
  data: {"prompt_id":"123e4567-e89b-12d3-a456-426614174000"}

  event: agent
  data: {"name":"relace-search","content":"I'll explore the codebase to understand where global styles and UI components are defined. Let me first get an overview of the project structure to identify relevant directories and files.\n\n"}

  event: tool
  data: {"name":"view_directory","path":"/repo"}

  event: tool
  data: {"name":"bash","command":"find /repo -type f -name \"*.css\" -o -name \"*.scss\" -o -name \"*.sass\" -o -name \"*.less\" | head -20"}

  event: tool
  data: {"name":"bash","command":"find /repo -type f -name \"*component*\" -o -name \"*ui*\" -o -name \"*style*\" | head -20"}

  event: tool
  data: {"name":"bash","command":"grep -r \"global.*style\\|style.*global\" /repo --include=\"*.js\" --include=\"*.ts\" --include=\"*.jsx\" --include=\"*.tsx\" | head -10"}

  event: tool
  data: {"name":"bash","command":"grep -r \"ThemeProvider\\|GlobalStyle\\|styled\\.\" /repo --include=\"*.js\" --include=\"*.ts\" --include=\"*.jsx\" --include=\"*.tsx\" | head -10"}

  event: agent
  data: {"name":"relace-search","content":"Based on the initial exploration, I can see this appears to be a React project with a structured component system. Let me dive deeper into the key areas that would contain global styles and UI components.\n\n"}

  event: tool
  data: {"name":"view_directory","path":"/repo/src/components"}

  event: tool
  data: {"name":"view_file","path":"/repo/src/index.css"}

  event: tool
  data: {"name":"view_directory","path":"/repo/src/components/ui"}

  event: tool
  data: {"name":"view_file","path":"/repo/src/main.tsx"}

  event: tool
  data: {"name":"bash","command":"find /repo/src -name \"*.css\" -o -name \"*.scss\" -o -name \"*.sass\" | xargs ls -la"}

  event: agent
  data: {"name":"relace-search","content":"Let me also check for any theme-related files and the main app structure to better understand how global styles and UI components are organized.\n\n"}

  event: tool
  data: {"name":"bash","command":"find /repo -name \"*theme*\" -type f"}

  event: tool
  data: {"name":"view_file","path":"/repo/src/hooks/use-theme.tsx"}

  event: tool
  data: {"name":"bash","command":"grep -r \"global.*style\\|style.*global\\|ThemeProvider\\|styled\\.\" /repo/src --include=\"*.tsx\" --include=\"*.ts\" | head -10"}

  event: tool
  data: {"name":"view_file","path":"/repo/src/App.tsx"}

  event: tool
  data: {"name":"bash","command":"ls -la /repo/src/components/"}

  event: agent
  data: {"name":"relace-search","content":"Based on my exploration of the codebase, I now have a clear understanding of where global styles and UI components are defined. Let me report back with my findings.\n\n"}

  event: tool
  data: {"name":"report_back","explanation":"Based on my exploration of the codebase, I've identified the key locations where global styles and UI components are defined:\n\n1. **Global Styles**: The global styles are defined in `/src/index.css`. ...","files":{"src/index.css":[[1,100]],"src/components/ui":[[1,100]],"src/hooks/use-theme.tsx":[[1,100]],"src/components/theme-toggle.tsx":[[1,50]],"src/App.tsx":[[1,20]]}}

  event: done
  data: {}
  ```
</ResponseExample>
