The transcript extraction used len(history) to find new messages, but history includes session_meta entries that are stripped before passing to the agent. This mismatch caused 1 message to be lost from the transcript on every turn after the first, because the slice offset was too high. Use the filtered history length (history_offset) returned by _run_agent instead. Also changed the else branch from returning all agent_messages to returning an empty list, so compressed/shorter agent output does not duplicate the entire history into the transcript.
11 KiB
11 KiB