postCodeContext method

Future<ContextBundle?> postCodeContext(
  1. ContextIn contextIn
)

Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt.

Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt. It retrieves seed spans, expands each with the definitions it calls and its key callers, then greedily fills the budget, so the answer is a coherent slice of the codebase rather than a list of disconnected matches. The top match is always included, truncated if it alone overflows, so a matched query never comes back empty. A retrieval outage answers 200 with an empty bundle rather than a 5xx.

Parameters:

Implementation

Future<ContextBundle?> postCodeContext(ContextIn contextIn,) async {
  final response = await postCodeContextWithHttpInfo(contextIn,);
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ContextBundle',) as ContextBundle;

  }
  return null;
}