---
title: response | CodeWeaver Docs
description: API reference for codeweaver.server.agent_api.search.response
url: "https://docs.knitli.com/api/server/agent_api/search/response"
type: static
generatedAt: "2026-04-17T17:21:09.687Z"
---

# response
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/server/agent_api/search/response.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F&text=response)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F&text=response)[Share on Bluesky](https://bsky.app/intent/compose?text=response%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F&title=response)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F&t=response)[Share on Email](mailto:?subject=response&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F)[Share on WhatsApp](https://wa.me/?text=response%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2Fresponse%2F&text=response)
# `codeweaver.server.agent_api.search.response`
[Section titled “codeweaver.server.agent_api.search.response”](#codeweaverserveragent_apisearchresponse)
Response building utilities for find_code.

This module handles the construction of FindCodeResponseSummary objects from search results, including summary generation and metadata calculation.

## Function: `build_error_response`
[Section titled “Function: build_error_response”](#function-build_error_response)

**

```
build_error_response()
```

Build an error response with graceful degradation.

Args: error: Exception that occurred query_intent: Optional detected query intent execution_time_ms: Execution time in milliseconds

Returns: FindCodeResponseSummary indicating failure

## Function: `build_success_response`
[Section titled “Function: build_success_response”](#function-build_success_response)

**

```
build_success_response()
```

Build a successful FindCodeResponseSummary.

Args: code_matches: List of code matches to include query: Original search query intent_type: Detected query intent total_candidates: Total number of candidates before limiting token_limit: Maximum token limit execution_time_ms: Execution time in milliseconds strategies_used: List of search strategies used

Returns: FindCodeResponseSummary with all fields populated

## Function: `calculate_token_count`
[Section titled “Function: calculate_token_count”](#function-calculate_token_count)

**

```
calculate_token_count()
```

Calculate approximate token count from code matches.

Args: code_matches: List of code matches to count tokens for token_limit: Maximum token limit to enforce

Returns: Estimated token count, capped at token_limit

## Function: `extract_languages`
[Section titled “Function: extract_languages”](#function-extract_languages)

**

```
extract_languages()
```

Extract unique programming languages from code matches.

Args: code_matches: List of code matches

Returns: Tuple of unique languages found (excludes ConfigLanguage)

## Function: `generate_summary`
[Section titled “Function: generate_summary”](#function-generate_summary)

**

```
generate_summary()
```

Generate a human-readable summary of search results.

Args: code_matches: List of code matches intent_type: Detected query intent query: Original search query

Returns: Summary string (max 1000 characters)

## Function: `get_indexer_state_info`
[Section titled “Function: get_indexer_state_info”](#function-get_indexer_state_info)

**

```
get_indexer_state_info()
```

Get indexing state and coverage from global application state.

Returns: Tuple of (indexing_state, index_coverage):

 - indexing_state: “complete”, “in_progress”, “not_started”, or “unknown”
 - index_coverage: Percentage of files indexed (0-100), or None if unavailable