Fix: don't skip user messages to extract identity #125
Conversation
EntelligenceAI PR SummaryRefactors identity update logic in
Confidence Score: 2/5 - Changes NeededNot safe to merge — the refactor in Key Findings:
Files requiring special attention
|
There was a problem hiding this comment.
Refactors identity update logic in anton/core/session.py to use a buffered, batched approach for richer context across conversation turns.
- Introduced
_identity_bufferlist to accumulate user inputs across turns - Every 5 turns, all buffered inputs are joined into a single concatenated string and passed to
maybe_update_identity - Buffer is cleared after each batch dispatch
- Removed the prior
isinstance(user_input, str)type guard
| self._persist_history() | ||
| if self._cortex is not None and self._cortex.mode != "off": | ||
| if self._turn_count % 5 == 0 and isinstance(user_input, str): | ||
| asyncio.create_task(self._cortex.maybe_update_identity(user_input)) | ||
| self._identity_buffer.append(user_input) | ||
| if self._turn_count % 5 == 0: | ||
| buffered = "\n\n".join(self._identity_buffer) | ||
| self._identity_buffer.clear() |
There was a problem hiding this comment.
Correctness: user_input is typed str | list[dict], and the old code guarded with isinstance(user_input, str) before using it; the new code unconditionally appends it to _identity_buffer: list[str], so when user_input is a list[dict], the subsequent "\n\n".join(self._identity_buffer) raises TypeError: sequence item N: expected str instance, list found.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In anton/core/session.py around line 784, the diff removed the `isinstance(user_input, str)` guard before appending to `self._identity_buffer`. Since `user_input` is typed `str | list[dict]`, appending a `list[dict]` value to `_identity_buffer: list[str]` and then calling `'\n\n'.join(self._identity_buffer)` at line 787 will raise a TypeError at runtime. Fix: wrap the append in `if isinstance(user_input, str):` to restore the original type guard, while keeping the new buffering/flush logic intact.
|
Nice catch on the missing messages. One concern on the approach: Minor: this diff references |
326dfe2
self._cortex.maybe_update_identityis called on every 5th message. and only the last message is sent to itFix: accumulate previous messages and send all of them on 5th step