feat(agents,backends,conversations,frontends,ui): progress thinking is told apart by its agent, raycast reasoning stays collapsed, read_conversation keeps progress
This commit is contained in:
1 parent
13873f857b
commit
120985deab
18 files changed
+374
-110
No files matched your search
@@ -23,7 +23,7 @@ from claude_agent_sdk import (
|
||||
)
|
||||
|
||||
from beaver_gateway.backends.capture import TurnCapture
|
||||
from beaver_gateway.backends.transcript import text_of
|
||||
from beaver_gateway.backends.transcript import reply_text, text_of
|
||||
from beaver_gateway.conversations import injects
|
||||
from beaver_gateway.conversations.seeds import Seeds
|
||||
from beaver_gateway.conversations.state import Runner, aware, iso
|
||||
@@ -32,11 +32,11 @@ from beaver_gateway.frontends.accumulate import StreamAccumulator
|
||||
from beaver_gateway.storage.models import Conversation, InjectQueueItem, RateLimit
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import AsyncIterator, Callable, Iterable, Sequence
|
||||
from collections.abc import AsyncIterator, Callable, Sequence
|
||||
|
||||
from beaver_gateway.events.stream import MessageStreamEvent
|
||||
|
||||
__all__ = ["Turns", "content_of", "image_block", "reply_text"]
|
||||
__all__ = ["Turns", "content_of", "image_block"]
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
@@ -164,7 +164,9 @@ class Turns(Seeds):
|
||||
):
|
||||
acc.feed(event)
|
||||
message = acc.finalize(model=agent.model)
|
||||
return reply_text(message.content), capture
|
||||
return reply_text(
|
||||
message.content, thinking_is_progress=agent.thinking_is_progress
|
||||
), capture
|
||||
|
||||
async def before_turn(self, conv: Conversation) -> str | None: # noqa: ARG002
|
||||
return None
|
||||
@@ -484,22 +486,6 @@ class Turns(Seeds):
|
||||
IMAGE_MAX_BYTES = 5 * 1024 * 1024
|
||||
|
||||
|
||||
def reply_text(content: Iterable[Any]) -> str:
|
||||
"""Text blocks plus non-empty thinking blocks, in block order.
|
||||
|
||||
What the model writes between tool calls rides in thinking blocks; the
|
||||
hidden reasoning in them is empty and drops out on its own.
|
||||
"""
|
||||
parts: list[str] = []
|
||||
for block in content:
|
||||
kind = getattr(block, "type", "")
|
||||
if kind == "text":
|
||||
parts.append(getattr(block, "text", "") or "")
|
||||
elif kind == "thinking":
|
||||
parts.append(getattr(block, "thinking", "") or "")
|
||||
return "\n\n".join(p for p in parts if p).strip()
|
||||
|
||||
|
||||
def content_of(
|
||||
text: str, attachments: Sequence[dict[str, Any]] | None
|
||||
) -> str | list[dict[str, Any]]:
|
||||
|
||||
Reference in new issue
Block a user