chenfei-wu/TaskMatrix · error

failed to extend_workflow, msg:%s, request data:%s

Error message

failed to extend_workflow, msg:%s, request data:%s

What it means

Flask error log from the /api/extend_workflow endpoint. Thrown when the JSON body lacks task_prompt/current_workflow/step, or when llm.extend_workflow fails (OpenAI error or SOP format parse failure).

Source

Thrown at LowCodeLLM/src/app.py:48

        workflow = llm.get_workflow(task_prompt)
        return workflow, 200
    except Exception as e:
        app.logger.error(
            'failed to get_workflow, msg:%s, request data:%s' % (str(e), request.json))
        return {'errmsg': 'internal errors'}, 500

@app.route('/api/extend_workflow', methods=['POST'])
@cross_origin()
def extend_workflow():
    try:
        request_content = request.get_json()
        task_prompt = request_content['task_prompt']
        current_workflow = request_content['current_workflow']
        step = request_content['step']
        sub_workflow = llm.extend_workflow(task_prompt, current_workflow, step)
        return sub_workflow, 200
    except Exception as e:
        app.logger.error(
            'failed to extend_workflow, msg:%s, request data:%s' % (str(e), request.json))
        return {'errmsg': 'internal errors'}, 500

@app.route('/api/execute', methods=['POST'])
@cross_origin()
def execute():
    try:
        request_content = request.get_json()
        task_prompt = request_content['task_prompt']
        confirmed_workflow = request_content['confirmed_workflow']
        curr_input = request_content['curr_input']
        history = request_content['history']
        response = llm.execute(task_prompt,confirmed_workflow, history, curr_input)
        return response, 200
    except Exception as e:
        app.logger.error(
            'failed to execute, msg:%s, request data:%s' % (str(e), request.json))
        return {'errmsg': 'internal errors'}, 500

View on GitHub (pinned to 4b7664f8d3)

Solutions

  1. Read the logged msg:%s to identify the exception (KeyError vs openai error).
  2. Ensure the body contains all three fields as JSON: task_prompt (string), current_workflow (string), step (string).
  3. Verify OPENAIKEY and, if USE_AZURE=true, API_BASE/API_VERSION/MODEL are set for the server process.

Example fix

// before
curl -X POST .../api/extend_workflow -d '{"step":"write"}'
// after
curl -X POST .../api/extend_workflow \
  -H 'Content-Type: application/json' \
  -d '{"task_prompt":"essay","current_workflow":"STEP 1: ...","step":"write the text"}'
Defensive patterns

Strategy: validation

Validate before calling

assert all(k in body for k in ('task_prompt','current_workflow','step')) and all(isinstance(body[k], str) for k in body)

Type guard

def is_extend_payload(b) -> bool:
    return (isinstance(b, dict)
            and isinstance(b.get('task_prompt'), str)
            and isinstance(b.get('current_workflow'), str)
            and isinstance(b.get('step'), str))

Try / catch

try: requests.post(url, json=body, timeout=30).raise_for_status()
except requests.HTTPError as e: log(e.response.text)

Prevention

When it happens

Trigger: POST /api/extend_workflow missing any of the three required keys ('task_prompt', 'current_workflow', 'step'), sending non-JSON, or an OpenAI failure (bad/missing OPENAIKEY, Azure misconfiguration) inside planningLLM.extend_workflow.

Common situations: Frontend sends current_workflow as a dict instead of the JSON string the prompt-building code concatenates, one key is misspelled, or env vars for OpenAI/Azure are not exported in the server process.

Related errors


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