diff --git a/src/acp/observer.lisp b/src/acp/observer.lisp index d2e224be..5a426898 100644 --- a/src/acp/observer.lisp +++ b/src/acp/observer.lisp @@ -139,10 +139,11 @@ (defmethod agent-observer-text ((observer acp-observer) text) "Stream assistant text and retain its length for nonstreamed response reconciliation." (acp-session-check-cancelled (acp-observer-session observer)) - (with-lock-held ((acp-observer-lock observer)) - (text-buffer-append (acp-observer-streamed-text observer) text) - (acp-observer--send observer - (agentcomms:acp-update-agent-message (agentcomms:acp-text-content text)))) + (when (plusp (length text)) + (with-lock-held ((acp-observer-lock observer)) + (text-buffer-append (acp-observer-streamed-text observer) text) + (acp-observer--send observer + (agentcomms:acp-update-agent-message (agentcomms:acp-text-content text))))) nil) (defmethod agent-observer-reasoning ((observer acp-observer) text) diff --git a/tests/acp-observer-tests.lisp b/tests/acp-observer-tests.lisp index 35a27ff7..0c07b6f9 100644 --- a/tests/acp-observer-tests.lisp +++ b/tests/acp-observer-tests.lisp @@ -200,6 +200,9 @@ (agent-observer-status observer ':provider-request-started nil) (agent-observer-reasoning observer "before ") (agent-observer-reasoning observer "approval") + (agent-observer-reasoning observer "continued ") + (agent-observer-text observer "") + (agent-observer-reasoning observer "thought") (test-assert (acp-observer--approval observer "shell.run" (json-object "command" "pwd") '(:command)) "the editor can approve after receiving pending thoughts") @@ -209,7 +212,8 @@ (mapcar #'agentcomms:acp-update-kind updates)) "thought batches precede the next message and permission request") (test-assert - (equal (list (format nil "first thought~2%next thought") "answer" "before approval") + (equal (list (format nil "first thought~2%next thought") "answer" + (format nil "before approvalcontinued thought")) (mapcar (lambda (update) (agentcomms:acp-content-text (agentcomms:json-get update "content"))) updates))