mirror of https://github.com/aliasrobotics/cai.git
fix: assign _last_user_input before Runner.run() to avoid UnboundLocalError on first compact
This commit is contained in:
parent
6ee2f0d66b
commit
0235e9a284
|
|
@ -1500,6 +1500,10 @@ def run_cai_cli(
|
|||
{"role": "assistant", "content": f"{result.final_output}"}
|
||||
)
|
||||
else:
|
||||
# Capture user_input before runner calls so ContextCompactedError
|
||||
# handlers can reference it even on the very first iteration.
|
||||
_last_user_input = user_input if isinstance(user_input, str) else ""
|
||||
|
||||
# Disable streaming by default, unless specifically enabled
|
||||
cai_stream = os.getenv("CAI_STREAM", "false")
|
||||
# Handle empty string or None values
|
||||
|
|
@ -1757,9 +1761,6 @@ def run_cai_cli(
|
|||
agent.model.message_history[:] = fix_message_list(agent.model.message_history)
|
||||
turn_count += 1
|
||||
|
||||
# Capture user_input here so auto-compact can replay it after clearing history.
|
||||
_last_user_input = user_input if isinstance(user_input, str) else ""
|
||||
|
||||
# Auto-compact: when CAI_SUPPORT_MODEL + CAI_SUPPORT_INTERVAL are both set,
|
||||
# compact the conversation every N LLM *responses* (assistant messages in
|
||||
# history) using the support model. Counting assistant messages rather
|
||||
|
|
|
|||
Loading…
Reference in New Issue