feat(backends,conversations,frontends): opus 5.5 progress updates reach telegram, current claude cli in the image
This commit is contained in:
1 parent
e58153628c
commit
bbce425eeb
9 files changed
+140
-20
No files matched your search
@@ -20,7 +20,11 @@ from claude_agent_sdk import (
|
||||
project_key_for_directory,
|
||||
)
|
||||
|
||||
from anthropic.types import TextBlock as AnthropicTextBlock
|
||||
from anthropic.types import ThinkingBlock
|
||||
|
||||
from beaver_gateway.agents.claude import ClaudeAgent, ClaudeOptions
|
||||
from beaver_gateway.conversations.turns import reply_text
|
||||
from beaver_gateway.backends.claude_sdk import ClaudeSdkBackend
|
||||
from beaver_gateway.events.bus import EventBus
|
||||
from beaver_gateway.conversations.service import (
|
||||
@@ -958,3 +962,17 @@ async def test_subagent_result_inside_a_turn_does_not_end_it(world: World) -> No
|
||||
assert client.prompts[-1].startswith("two")
|
||||
rows = await world.conversations.queue.recent(conv.id)
|
||||
assert [r.status for r in rows] == ["done", "done"]
|
||||
|
||||
|
||||
def test_reply_text_keeps_progress_updates_and_drops_hidden_reasoning() -> None:
|
||||
blocks = [
|
||||
ThinkingBlock(type="thinking", thinking="", signature="s"),
|
||||
ThinkingBlock(type="thinking", thinking="looking it up", signature="s"),
|
||||
AnthropicTextBlock(type="text", text="found it"),
|
||||
]
|
||||
assert reply_text(blocks) == "looking it up\n\nfound it"
|
||||
|
||||
|
||||
def test_reply_text_on_a_plain_answer_is_unchanged() -> None:
|
||||
blocks = [AnthropicTextBlock(type="text", text=" just an answer ")]
|
||||
assert reply_text(blocks) == "just an answer"
|
||||
@@ -20,6 +20,7 @@ from beaver_gateway.frontends.base import GatewayRuntime
|
||||
from beaver_gateway.frontends.files import SendFileError, SendFiles, method_for
|
||||
from beaver_gateway.frontends.telegram import Attachments, TelegramFrontend
|
||||
from beaver_gateway.frontends.telegram.drafts import Draft
|
||||
from beaver_gateway.frontends.telegram.texts import TelegramTexts
|
||||
from beaver_gateway.frontends.telegram.render import (
|
||||
LIMIT,
|
||||
chunks,
|
||||
@@ -1194,3 +1195,56 @@ async def test_a_refused_upload_comes_back_to_the_agent(stack: Stack) -> None:
|
||||
outside = await _send(stack, master, path="/etc/passwd")
|
||||
assert outside["is_error"]
|
||||
assert "outside the allowed roots" in outside["content"][0]["text"]
|
||||
|
||||
|
||||
def _progress_draft() -> Draft:
|
||||
return Draft(cast("Any", None), chat_id=USER, thread_id=None, turn_id="t")
|
||||
|
||||
|
||||
def _thinking_delta(text: str) -> Any:
|
||||
return {
|
||||
"event": {
|
||||
"type": "content_block_delta",
|
||||
"index": 0,
|
||||
"delta": {"type": "thinking_delta", "thinking": text},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def test_progress_updates_reach_the_draft_but_hidden_reasoning_does_not() -> None:
|
||||
draft = _progress_draft()
|
||||
texts = TelegramTexts()
|
||||
stub = SimpleNamespace(_drafts={"k": draft}, texts=texts)
|
||||
feed = functools.partial(TelegramFrontend._feed_draft, cast("Any", stub), "k")
|
||||
|
||||
feed(_thinking_delta(""))
|
||||
assert draft.text == ""
|
||||
assert draft.status == texts.thinking
|
||||
|
||||
feed(_thinking_delta("checking the vault"))
|
||||
assert draft.text == "checking the vault"
|
||||
assert draft.status == texts.writing
|
||||
|
||||
|
||||
def test_a_tool_call_between_progress_updates_starts_a_new_paragraph() -> None:
|
||||
draft = _progress_draft()
|
||||
texts = TelegramTexts()
|
||||
stub = SimpleNamespace(
|
||||
_drafts={"k": draft},
|
||||
texts=texts,
|
||||
_tool_status=lambda name, _input: texts.tool.format(label=name),
|
||||
)
|
||||
feed = functools.partial(TelegramFrontend._feed_draft, cast("Any", stub), "k")
|
||||
|
||||
feed(_thinking_delta("reading the note"))
|
||||
feed(
|
||||
{
|
||||
"event": {
|
||||
"type": "content_block_start",
|
||||
"index": 1,
|
||||
"content_block": {"type": "tool_use", "name": "Read"},
|
||||
}
|
||||
}
|
||||
)
|
||||
feed(_thinking_delta("now writing it back"))
|
||||
assert draft.text == "reading the note\n\nnow writing it back"
|
||||
Reference in new issue
Block a user