chenfei-wu/TaskMatrix · warning

Format error, please try again.

Error message

Format error, please try again.

What it means

Printed by planningLLM._txt2json when parsing the LLM's SOP text fails. The bare except catches any deviation from the expected 'STEP n: [name][description][[condition][Jump to STEP m]]' format — including AttributeError from re.search returning None, index errors from unbalanced brackets, or the model adding prose around the steps — and the function silently returns None.

Source

Thrown at LowCodeLLM/src/planningLLM.py:105

                step_id = step[: left_indices[0]-2]
                step_name = step[left_indices[0]+1: right_indices[0]]
                step_description = step[left_indices[1]+1: right_indices[1]]
                jump_str = step[left_indices[2]+1: right_indices[-1]]
                if re.findall(re.compile(r'[A-Za-z]',re.S), jump_str) == []:
                    workflow.append({"stepId": step_id, "stepName": step_name, "stepDescription": step_description, "jumpLogic": [], "extension": []})
                    continue
                jump_logic = []
                left_indices = [_.start() for _ in re.finditer('\[', jump_str)]
                right_indices = [_.start() for _ in re.finditer('\]', jump_str)]
                i = 1
                while i < len(left_indices):
                    jump = {"Condition": jump_str[left_indices[i]+1: right_indices[i-1]], "Target": re.search(r'STEP\s\d', jump_str[left_indices[i+1]+1: right_indices[i]]).group(0)}
                    jump_logic.append(jump)
                    i += 3
                workflow.append({"stepId": step_id, "stepName": step_name, "stepDescription": step_description, "jumpLogic": jump_logic, "extension": []})
            return json.dumps(workflow)
        except:
            print("Format error, please try again.")

View on GitHub (pinned to 4b7664f8d3)

Solutions

  1. Retry the get_workflow/extend_workflow call — the message itself says 'please try again' since output is nondeterministic.
  2. Lower the temperature passed to planningLLM to make format adherence more reliable.
  3. Make _txt2json robust: skip non-conforming lines, guard re.search result before .group(0), and re-raise/log the exception instead of a bare print.
  4. Strengthen the prompt suffix or validate the LLM output with a schema and re-prompt on failure.

Example fix

# before
jump = {"Condition": ..., "Target": re.search(r'STEP\s\d', s).group(0)}
except:
    print("Format error, please try again.")
# after
m = re.search(r'STEP\s\d+', s)
if m is None:
    continue
jump = {"Condition": ..., "Target": m.group(0)}
except (IndexError, AttributeError) as e:
    logging.exception('SOP parse failed: %s', e)
raise  # or return error sentinel the caller can retry on
Defensive patterns

Strategy: retry

Validate before calling

def looks_like_sop(text: str) -> bool:
    lines = [l for l in text.split('\n') if l.strip()]
    return bool(lines) and sum(l.startswith('STEP') for l in lines) >= 1

Try / catch

wf = llm.get_workflow(task)
if wf is None or wf == 'OpenAI API error.':
    wf = llm.get_workflow(task)  # format failures are stochastic; retry once

Prevention

When it happens

Trigger: The LLM reply deviates from the strict STEP format: missing 'STEP' prefix, unbalanced [ ] brackets so left/right index lists misalign, jump text without a 'STEP n' target (re.search returns None -> .group(0) raises AttributeError), or extra commentary lines that pass the STEP filter but have fewer than 3 bracket groups.

Common situations: Weaker models (gpt-3.5-turbo) ignore the format instructions occasionally; temperature too high increases deviation; user task prompts that induce the model to answer the task instead of producing an SOP. Downstream this becomes a None workflow returned to the Flask endpoint and surfaced as the 'internal errors' 500.

Related errors


AI-assisted analysis of chenfei-wu/TaskMatrix@4b7664f8d3 (2026-08-27). Data as JSON: /api/errors/529aaeb6683b4fa8. Report an issue: GitHub.