mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend/copilot): manually append CLI transcript to previous when CLI fails to append
This commit is contained in:
@@ -1552,15 +1552,39 @@ async def stream_chat_completion_sdk(
|
||||
logger.info(
|
||||
"%s Transcript upload: source=%s, "
|
||||
"stop_hook_fired=%s, captured_len=%d, "
|
||||
"raw_len=%d, use_resume=%s",
|
||||
"raw_len=%d, use_resume=%s, previous_len=%d",
|
||||
log_prefix,
|
||||
source,
|
||||
bool(captured_transcript.path),
|
||||
len(captured_transcript.raw_content),
|
||||
len(raw_transcript) if raw_transcript else 0,
|
||||
use_resume,
|
||||
(
|
||||
len(previous_transcript_content)
|
||||
if previous_transcript_content
|
||||
else 0
|
||||
),
|
||||
)
|
||||
|
||||
# When using --resume, CLI should append new turn to old transcript.
|
||||
# But sometimes CLI writes only the new turn (incomplete).
|
||||
# Fix: If raw_transcript is smaller than previous, manually append.
|
||||
if (
|
||||
use_resume
|
||||
and previous_transcript_content
|
||||
and raw_transcript
|
||||
and len(raw_transcript) < len(previous_transcript_content)
|
||||
):
|
||||
logger.warning(
|
||||
"%s CLI transcript smaller than previous (%dB < %dB) - "
|
||||
"manually appending new turn to previous",
|
||||
log_prefix,
|
||||
len(raw_transcript),
|
||||
len(previous_transcript_content),
|
||||
)
|
||||
# Append new turn to previous transcript
|
||||
raw_transcript = previous_transcript_content + raw_transcript
|
||||
|
||||
if raw_transcript and session is not None:
|
||||
await asyncio.shield(
|
||||
_try_upload_transcript(
|
||||
|
||||
@@ -479,6 +479,8 @@ async def upload_transcript(
|
||||
len(stripped),
|
||||
len(content),
|
||||
)
|
||||
logger.warning("%s Raw content preview: %s", log_prefix, content[:500])
|
||||
logger.warning("%s Stripped content: %s", log_prefix, stripped[:500])
|
||||
return
|
||||
|
||||
storage = await get_workspace_storage()
|
||||
|
||||
Reference in New Issue
Block a user