Skip to content

Fix auto chat rename for large histories#1746

Open
ruizanthony wants to merge 1 commit into
agent0ai:mainfrom
ruizanthony:fix/auto-chat-rename-large-history
Open

Fix auto chat rename for large histories#1746
ruizanthony wants to merge 1 commit into
agent0ai:mainfrom
ruizanthony:fix/auto-chat-rename-large-history

Conversation

@ruizanthony

Copy link
Copy Markdown

Summary

Fixes automatic chat renaming when chat histories are large or contain structured/tool-call messages.

The previous implementation serialised the full chat history with history.output_text(), which can become very large and make auto rename slow or fail silently. It could also persist invalid utility-model responses such as JSON/tool-call payloads as chat titles.

Changes

  • Build the rename prompt from a bounded set of recent messages via history.all_messages() when available.
  • Ignore tool-call/tool-result payloads while extracting history text for chat titles.
  • Normalize and validate model-generated names before saving them.
  • Accept useful JSON wrappers such as {\"headline\": \"...\"} while rejecting tool-call JSON.
  • Add a local fallback title generator, used especially for forced auto rename flows.
  • Save the renamed context and notify the state monitor so the sidebar refreshes.
  • Log auto-rename failures instead of swallowing them silently.

Verification

  • PYTHONPATH=/tmp/a0-pr-auto-chat-rename /a0/venv/bin/python -m py_compile extensions/python/monologue_start/_60_rename_chat.py
  • Smoke test for:
    • accepting normal chat-title strings;
    • rejecting obvious UI dumps;
    • accepting JSON headline wrappers;
    • rejecting tool-call JSON;
    • extracting bounded recent history;
    • forced fallback rename path.

Build chat rename prompts from bounded recent messages instead of serializing full history.

Validate model-generated titles and add a local fallback for forced auto rename.

Refresh chat state after saving renamed contexts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant