binary-husky/gpt_academic · error · Exception

未收到第 {i + 1} 个响应

Error message

未收到第 {i + 1} 个响应

What it means

QueryAnalyzer expects responses to contain at least 2*len(prompts) entries (alternating user/assistant turns); when the collected list is shorter, index i*2+1 falls outside it and the code raises Exception('未收到第 {i+1} 个响应'). This means one or more of the fanned-out LLM requests never delivered its turn at all — stronger than error 90, where the slot exists but holds None.

Source

Thrown at crazy_functions/review_fns/query_analyzer.py:190

                sys_prompt_array=sys_prompts,
                max_workers=5
            )

            # 从收集的响应中提取我们需要的内容
            extracted_responses = []
            for i in range(len(prompts)):
                if (i * 2 + 1) < len(responses):
                    response = responses[i * 2 + 1]
                    if response is None:
                        raise Exception(f"Response {i} is None")
                    if not isinstance(response, str):
                        try:
                            response = str(response)
                        except:
                            raise Exception(f"Cannot convert response {i} to string")
                    extracted_responses.append(response)
                else:
                    raise Exception(f"未收到第 {i + 1} 个响应")

            # 解析基本信息
            query_type = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "query_type")
            if not query_type:
                print(
                    f"Debug - Failed to extract query_type. Response was: {extracted_responses[self.BASIC_QUERY_INDEX]}")
                raise Exception("无法提取query_type标签内容")
            query_type = query_type.lower()

            main_topic = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "main_topic")
            if not main_topic:
                print(f"Debug - Failed to extract main_topic. Using query as fallback.")
                main_topic = query

            query_type = self._normalize_query_type(query_type, query)

            # 解析arXiv参数
            try:

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Retry the analysis — partial collection is usually transient (worker crash/timeout).
  2. Log len(responses) vs len(prompts): a systematic mismatch (e.g. exactly len(prompts) responses) means the bridge no longer interleaves turns and the i*2+1 indexing in query_analyzer.py:182 must be updated to i.
  3. Check backend logs for a worker exception at the same timestamp.
  4. Verify the bridge version/contract: if responses are assistant-only, read responses[i] instead.

Example fix

# before
response = responses[i * 2 + 1]

# after (if the bridge returns one entry per prompt, no interleaving)
response = responses[i] if len(responses) == len(prompts) else responses[i * 2 + 1]
Defensive patterns

Strategy: validation

Validate before calling

def response_count_ok(responses: list, prompt_count: int) -> bool:
    # bridge contract: interleaved user/assistant turns -> 2 per prompt
    return len(responses) >= prompt_count * 2

Try / catch

try:
    result = analyzer.analyze(query)
except Exception as e:
    if '未收到' in str(e):
        logger.warning('partial LLM fan-out, retrying once')
        result = analyzer.analyze(query)
    else:
        raise

Prevention

When it happens

Trigger: The multi-request bridge returns fewer turns than prompts sent: a worker crashed before appending its response, an exception aborted collection mid-way, or a silent short-circuit in the executor dropped one request entirely.

Common situations: Thread-pool exceptions swallowed inside the bridge so a turn is never appended; timeouts that terminate collection early; version drift between QueryAnalyzer's indexing assumption (i*2+1) and a bridge that changed its response layout (e.g. stopped interleaving user turns).

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/1a4d7b9dc04fd41a. Report an issue: GitHub.