graphcore-apps 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agents/__init__.py +0 -0
- agents/apps.py +15 -0
- agents/authorization.py +62 -0
- agents/conf.py +78 -0
- agents/delegation.py +218 -0
- agents/entities/__init__.py +0 -0
- agents/entities/agent.py +16 -0
- agents/entities/conversation.py +23 -0
- agents/entities/instruction.py +7 -0
- agents/entities/message.py +30 -0
- agents/entities/profile.py +14 -0
- agents/entities/skill.py +8 -0
- agents/migrations/0001_initial.py +88 -0
- agents/migrations/0002_message_context_versions.py +16 -0
- agents/migrations/0003_compaction_threshold.py +21 -0
- agents/migrations/0004_agent_debug_context.py +16 -0
- agents/migrations/0005_conversation_last_active_at.py +34 -0
- agents/migrations/0006_tasks.py +21 -0
- agents/migrations/0007_agent_start_address.py +16 -0
- agents/migrations/__init__.py +0 -0
- agents/models.py +64 -0
- agents/persistence.py +18 -0
- agents/providers/__init__.py +0 -0
- agents/providers/anthropic.py +142 -0
- agents/providers/fake.py +51 -0
- agents/providers/google.py +186 -0
- agents/providers/openai.py +177 -0
- agents/providers/port.py +101 -0
- agents/providers/registry.py +40 -0
- agents/routes.py +5 -0
- agents/runtime/__init__.py +0 -0
- agents/runtime/compaction.py +29 -0
- agents/runtime/context.py +78 -0
- agents/runtime/dispatch.py +76 -0
- agents/runtime/effective_agent.py +70 -0
- agents/runtime/loop.py +454 -0
- agents/runtime/prompt.py +183 -0
- agents/runtime/resume.py +30 -0
- agents/runtime/tools.py +35 -0
- agents/specs/__init__.py +3 -0
- agents/specs/dsl.py +310 -0
- agents/specs/test_r01_agents.py +74 -0
- agents/specs/test_r02_conversations.py +146 -0
- agents/specs/test_r03_acts_as_the_sender.py +60 -0
- agents/specs/test_r04_context.py +63 -0
- agents/specs/test_r05_personal_configuration.py +86 -0
- agents/specs/test_r06_delegation.py +70 -0
- agents/specs/test_r07_sharing.py +103 -0
- agents/specs/test_r08_embedding.py +40 -0
- agents/specs/test_r09_finding.py +41 -0
- agents/specs/test_r10_clients.py +41 -0
- agents/strategies/__init__.py +0 -0
- agents/strategies/_schema.py +16 -0
- agents/strategies/agents.py +93 -0
- agents/strategies/context.py +45 -0
- agents/strategies/conversations.py +65 -0
- agents/strategies/instructions.py +62 -0
- agents/strategies/messages.py +56 -0
- agents/strategies/models.py +27 -0
- agents/strategies/profiles.py +43 -0
- agents/strategies/skills.py +47 -0
- agents/strategies/turn.py +47 -0
- agents/test_settings.py +6 -0
- agents/tests/__init__.py +0 -0
- agents/tests/support.py +94 -0
- agents/tests/test_agent_views.py +181 -0
- agents/tests/test_agents.py +166 -0
- agents/tests/test_anthropic_adapter.py +221 -0
- agents/tests/test_context.py +231 -0
- agents/tests/test_control.py +162 -0
- agents/tests/test_conversations.py +158 -0
- agents/tests/test_delegation.py +392 -0
- agents/tests/test_google_adapter.py +208 -0
- agents/tests/test_inspect.py +59 -0
- agents/tests/test_live_providers.py +69 -0
- agents/tests/test_openai_adapter.py +259 -0
- agents/tests/test_profiles.py +92 -0
- agents/tests/test_resumption.py +150 -0
- agents/tests/test_turns.py +230 -0
- agents/validation.py +48 -0
- agents_agent_frontend/__init__.py +3 -0
- agents_agent_frontend/agent_views.py +286 -0
- audio/__init__.py +0 -0
- audio/apps.py +14 -0
- audio/authorization.py +13 -0
- audio/conf.py +27 -0
- audio/entities/__init__.py +11 -0
- audio/entities/recording.py +10 -0
- audio/migrations/0001_initial.py +26 -0
- audio/migrations/__init__.py +0 -0
- audio/models.py +9 -0
- audio/persistence.py +6 -0
- audio/providers/__init__.py +0 -0
- audio/providers/fake.py +35 -0
- audio/providers/openai.py +50 -0
- audio/providers/port.py +31 -0
- audio/providers/registry.py +31 -0
- audio/specs/__init__.py +3 -0
- audio/specs/dsl.py +120 -0
- audio/specs/test_clients.py +20 -0
- audio/specs/test_dictation.py +87 -0
- audio/specs/test_privacy.py +45 -0
- audio/specs/test_vendor.py +59 -0
- audio/strategies/__init__.py +11 -0
- audio/strategies/recordings.py +88 -0
- audio/test_settings.py +6 -0
- audio/tests/__init__.py +0 -0
- audio/tests/test_openai_adapter.py +65 -0
- audio/tests/test_recordings.py +139 -0
- audio_agent_frontend/__init__.py +3 -0
- audio_agent_frontend/agent_views.py +11 -0
- graphcore_apps-0.5.0.dist-info/METADATA +14 -0
- graphcore_apps-0.5.0.dist-info/RECORD +118 -0
- graphcore_apps-0.5.0.dist-info/WHEEL +5 -0
- graphcore_apps-0.5.0.dist-info/entry_points.txt +7 -0
- graphcore_apps-0.5.0.dist-info/licenses/LICENSE +202 -0
- graphcore_apps-0.5.0.dist-info/licenses/NOTICE +2 -0
- graphcore_apps-0.5.0.dist-info/top_level.txt +4 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from django.test import override_settings
|
|
2
|
+
|
|
3
|
+
from graphcore.public.errors import InvalidRequest
|
|
4
|
+
|
|
5
|
+
from agents.entities.agent import Agent
|
|
6
|
+
from agents.models import AgentModel
|
|
7
|
+
from agents.strategies.agents import UpdateAgent
|
|
8
|
+
from agents.strategies.instructions import UpdateInstruction
|
|
9
|
+
from agents.strategies.models import ListModels
|
|
10
|
+
from agents.strategies.skills import UpdateSkill
|
|
11
|
+
from agents.tests.support import AgentsTestCase
|
|
12
|
+
|
|
13
|
+
MODELS = [{'id': 'fake/small', 'context_size': 1000}, {'id': 'anthropic/claude-sonnet-5-5', 'max_output_tokens': 4096}]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AgentTests(AgentsTestCase):
|
|
17
|
+
async def test_an_agent_without_a_target_is_top_level_and_owned_by_its_creator(self):
|
|
18
|
+
carl = await self.create_user('carl')
|
|
19
|
+
|
|
20
|
+
agent = await self.get_entity(carl, await self.create_agent(carl, description='Research'))
|
|
21
|
+
|
|
22
|
+
self.assertIsInstance(agent, Agent)
|
|
23
|
+
self.assertEqual((agent.name, agent.description, agent.model), ('Troy', 'Research', None))
|
|
24
|
+
self.assertEqual((agent.parent_id, agent.owner), (None, carl.principal_entity_id))
|
|
25
|
+
self.assertTrue(await AgentModel.objects.filter(entity_id=agent.entity_id, name='Troy').aexists())
|
|
26
|
+
|
|
27
|
+
async def test_update_sets_only_the_given_fields(self):
|
|
28
|
+
carl = await self.create_user('carl')
|
|
29
|
+
agent_id = await self.create_agent(carl, description='Research')
|
|
30
|
+
instruction_id = await self.create_instruction(carl)
|
|
31
|
+
|
|
32
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, instruction_ids=[instruction_id]))
|
|
33
|
+
|
|
34
|
+
agent = await self.get_entity(carl, agent_id)
|
|
35
|
+
self.assertEqual((agent.name, agent.description), ('Troy', 'Research'))
|
|
36
|
+
self.assertEqual(agent.instruction_ids, [instruction_id])
|
|
37
|
+
|
|
38
|
+
async def test_a_list_must_name_readable_entities_of_its_type(self):
|
|
39
|
+
carl = await self.create_user('carl')
|
|
40
|
+
dana = await self.create_user('dana')
|
|
41
|
+
skill_id = await self.create_skill(carl)
|
|
42
|
+
private = await self.create_instruction(dana)
|
|
43
|
+
|
|
44
|
+
with self.assertRaises(InvalidRequest):
|
|
45
|
+
await self.create_agent(carl, instruction_ids=[skill_id])
|
|
46
|
+
with self.assertRaises(InvalidRequest):
|
|
47
|
+
await self.create_agent(carl, instruction_ids=[private])
|
|
48
|
+
with self.assertRaises(InvalidRequest):
|
|
49
|
+
await self.create_agent(carl, name='x', skill_ids=['gc://nowhere/nothing'])
|
|
50
|
+
|
|
51
|
+
async def test_a_start_address_must_name_a_place(self):
|
|
52
|
+
carl = await self.create_user('carl')
|
|
53
|
+
agent_id = await self.create_agent(carl, start_address='/agents')
|
|
54
|
+
|
|
55
|
+
for wrong in ('/no-such-page', 'agents', 'gc://nowhere/nothing'):
|
|
56
|
+
with self.subTest(wrong), self.assertRaises(InvalidRequest):
|
|
57
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, start_address=wrong))
|
|
58
|
+
self.assertEqual((await self.get_entity(carl, agent_id)).start_address, '/agents')
|
|
59
|
+
|
|
60
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, start_address=None))
|
|
61
|
+
self.assertIsNone((await self.get_entity(carl, agent_id)).start_address)
|
|
62
|
+
|
|
63
|
+
@override_settings(AGENTS_MODELS=MODELS)
|
|
64
|
+
async def test_a_model_must_be_in_the_catalog(self):
|
|
65
|
+
carl = await self.create_user('carl')
|
|
66
|
+
|
|
67
|
+
agent_id = await self.create_agent(carl, model='fake/small')
|
|
68
|
+
with self.assertRaises(InvalidRequest):
|
|
69
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, model='fake/unlisted'))
|
|
70
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, model=None))
|
|
71
|
+
|
|
72
|
+
self.assertIsNone((await self.get_entity(carl, agent_id)).model)
|
|
73
|
+
|
|
74
|
+
async def test_a_compaction_threshold_is_a_fraction_or_null(self):
|
|
75
|
+
carl = await self.create_user('carl')
|
|
76
|
+
|
|
77
|
+
agent_id = await self.create_agent(carl, compaction_threshold=0.4)
|
|
78
|
+
for refused in (0, 1.5, 'half'):
|
|
79
|
+
with self.assertRaises(InvalidRequest):
|
|
80
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, compaction_threshold=refused))
|
|
81
|
+
self.assertEqual((await self.get_entity(carl, agent_id)).compaction_threshold, 0.4)
|
|
82
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, compaction_threshold=None))
|
|
83
|
+
|
|
84
|
+
self.assertIsNone((await self.get_entity(carl, agent_id)).compaction_threshold)
|
|
85
|
+
|
|
86
|
+
async def test_a_task_limit_is_a_whole_number_from_1_to_100_or_null(self):
|
|
87
|
+
carl = await self.create_user('carl')
|
|
88
|
+
|
|
89
|
+
agent_id = await self.create_agent(carl, max_tasks=3)
|
|
90
|
+
for refused in (0, 101, 2.5, 'many'):
|
|
91
|
+
with self.assertRaises(InvalidRequest):
|
|
92
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, max_tasks=refused))
|
|
93
|
+
self.assertEqual((await self.get_entity(carl, agent_id)).max_tasks, 3)
|
|
94
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, max_tasks=None))
|
|
95
|
+
|
|
96
|
+
self.assertIsNone((await self.get_entity(carl, agent_id)).max_tasks)
|
|
97
|
+
|
|
98
|
+
async def test_an_unknown_param_is_refused(self):
|
|
99
|
+
carl = await self.create_user('carl')
|
|
100
|
+
|
|
101
|
+
with self.assertRaises(InvalidRequest):
|
|
102
|
+
await self.create_agent(carl, colour='red')
|
|
103
|
+
|
|
104
|
+
@override_settings(AGENTS_MODELS=MODELS, AGENTS_DEFAULT_MODEL='fake/small', ANTHROPIC_API_KEY='')
|
|
105
|
+
async def test_list_models_returns_the_catalog_and_which_providers_can_be_reached(self):
|
|
106
|
+
carl = await self.create_user('carl')
|
|
107
|
+
|
|
108
|
+
listed = (await self.run_strategy(carl, ListModels.request_constructor())).ret_val
|
|
109
|
+
|
|
110
|
+
self.assertEqual(
|
|
111
|
+
(listed['default'], listed['compaction_threshold'], listed['max_tasks']), ('fake/small', 0.7, 10),
|
|
112
|
+
)
|
|
113
|
+
self.assertEqual(listed['models'], [
|
|
114
|
+
{'id': 'fake/small', 'context_size': 1000, 'max_output_tokens': 8192, 'available': True},
|
|
115
|
+
{'id': 'anthropic/claude-sonnet-5-5', 'context_size': 1000000, 'max_output_tokens': 4096,
|
|
116
|
+
'available': False},
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class InstructionAndSkillTests(AgentsTestCase):
|
|
121
|
+
async def test_attach_creates_it_inside_the_agent_and_appends_it_to_the_list(self):
|
|
122
|
+
carl = await self.create_user('carl')
|
|
123
|
+
agent_id = await self.create_agent(carl)
|
|
124
|
+
|
|
125
|
+
first = await self.create_instruction(carl, agent_id, attach=True)
|
|
126
|
+
second = await self.create_instruction(carl, agent_id, name='Tone', attach=True)
|
|
127
|
+
skill_id = await self.create_skill(carl, agent_id, attach=True)
|
|
128
|
+
|
|
129
|
+
agent = await self.get_entity(carl, agent_id)
|
|
130
|
+
self.assertEqual((agent.instruction_ids, agent.skill_ids), ([first, second], [skill_id]))
|
|
131
|
+
self.assertEqual((await self.get_entity(carl, first)).parent_id, agent_id)
|
|
132
|
+
|
|
133
|
+
async def test_without_attach_the_list_is_untouched(self):
|
|
134
|
+
carl = await self.create_user('carl')
|
|
135
|
+
agent_id = await self.create_agent(carl)
|
|
136
|
+
|
|
137
|
+
instruction_id = await self.create_instruction(carl, agent_id)
|
|
138
|
+
|
|
139
|
+
self.assertEqual((await self.get_entity(carl, agent_id)).instruction_ids, [])
|
|
140
|
+
self.assertEqual((await self.get_entity(carl, instruction_id)).parent_id, agent_id)
|
|
141
|
+
|
|
142
|
+
async def test_attach_needs_an_agent_or_profile_target(self):
|
|
143
|
+
carl = await self.create_user('carl')
|
|
144
|
+
|
|
145
|
+
with self.assertRaises(InvalidRequest):
|
|
146
|
+
await self.create_instruction(carl, attach=True)
|
|
147
|
+
|
|
148
|
+
async def test_a_top_level_instruction_and_skill_are_updated_by_their_owner(self):
|
|
149
|
+
carl = await self.create_user('carl')
|
|
150
|
+
instruction_id = await self.create_instruction(carl)
|
|
151
|
+
skill_id = await self.create_skill(carl)
|
|
152
|
+
|
|
153
|
+
await self.run_strategy(carl, UpdateInstruction.request_constructor(instruction_id, text='Be thorough.'))
|
|
154
|
+
await self.run_strategy(carl, UpdateSkill.request_constructor(skill_id, description='When researching'))
|
|
155
|
+
|
|
156
|
+
instruction = await self.get_entity(carl, instruction_id)
|
|
157
|
+
skill = await self.get_entity(carl, skill_id)
|
|
158
|
+
self.assertEqual((instruction.name, instruction.text), ('Brief', 'Be thorough.'))
|
|
159
|
+
self.assertEqual((skill.name, skill.description, skill.text), ('research', 'When researching', 'Search first.'))
|
|
160
|
+
|
|
161
|
+
async def test_an_agent_holds_only_instructions_and_skills(self):
|
|
162
|
+
carl = await self.create_user('carl')
|
|
163
|
+
agent_id = await self.create_agent(carl)
|
|
164
|
+
|
|
165
|
+
with self.assertRaises(InvalidRequest):
|
|
166
|
+
await self.create_agent(carl, agent_id, name='Nested')
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"""The Anthropic adapter against the SDK itself, with the HTTP transport replaced:
|
|
2
|
+
a `ModelRequest` becomes the wire request, a recorded stream becomes the port's
|
|
3
|
+
events, and each vendor error becomes its `code`."""
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
import httpx2
|
|
7
|
+
from anthropic import DefaultAsyncHttpxClient
|
|
8
|
+
from django.test import SimpleTestCase
|
|
9
|
+
|
|
10
|
+
from agents.providers.anthropic import AnthropicProvider
|
|
11
|
+
from agents.providers.port import (
|
|
12
|
+
Done, ModelRequest, ProviderError, TextDelta, ToolCall, ToolDef, ToolResult, Turn, Usage,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
OPEN = ToolDef('open', 'Read a place.', {"type": "object", "properties": {"at": {"type": "string"}}})
|
|
16
|
+
THINKING = {"type": "thinking", "thinking": "", "signature": "sig-1"}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def sse(*events: dict) -> bytes:
|
|
20
|
+
return b''.join(f"event: {e['type']}\ndata: {json.dumps(e)}\n\n".encode() for e in events)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def recorded_reply(stop_reason: str = 'tool_use') -> bytes:
|
|
24
|
+
"""A reply that thinks, says a sentence, and calls `open`."""
|
|
25
|
+
return sse(
|
|
26
|
+
{"type": "message_start", "message": {
|
|
27
|
+
"id": "msg_1", "type": "message", "role": "assistant", "model": "claude-sonnet-5-5", "content": [],
|
|
28
|
+
"stop_reason": None, "stop_sequence": None,
|
|
29
|
+
"usage": {"input_tokens": 12, "cache_creation_input_tokens": 30, "cache_read_input_tokens": 400,
|
|
30
|
+
"output_tokens": 1},
|
|
31
|
+
}},
|
|
32
|
+
{"type": "content_block_start", "index": 0,
|
|
33
|
+
"content_block": {"type": "thinking", "thinking": "", "signature": ""}},
|
|
34
|
+
{"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "sig-1"}},
|
|
35
|
+
{"type": "content_block_stop", "index": 0},
|
|
36
|
+
{"type": "content_block_start", "index": 1, "content_block": {"type": "text", "text": ""}},
|
|
37
|
+
{"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": "Looking"}},
|
|
38
|
+
{"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": " now."}},
|
|
39
|
+
{"type": "content_block_stop", "index": 1},
|
|
40
|
+
{"type": "content_block_start", "index": 2,
|
|
41
|
+
"content_block": {"type": "tool_use", "id": "toolu_1", "name": "open", "input": {}}},
|
|
42
|
+
{"type": "content_block_delta", "index": 2, "delta": {"type": "input_json_delta", "partial_json": '{"at": '}},
|
|
43
|
+
{"type": "content_block_delta", "index": 2, "delta": {"type": "input_json_delta", "partial_json": '"/notes"}'}},
|
|
44
|
+
{"type": "content_block_stop", "index": 2},
|
|
45
|
+
{"type": "message_delta", "delta": {"stop_reason": stop_reason, "stop_sequence": None},
|
|
46
|
+
"usage": {"output_tokens": 25}},
|
|
47
|
+
{"type": "message_stop"},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def error_response(status: int, error_type: str, message: str = 'no') -> httpx2.Response:
|
|
52
|
+
return httpx2.Response(status, json={"type": "error", "error": {"type": error_type, "message": message}})
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AnthropicAdapterTests(SimpleTestCase):
|
|
56
|
+
def provider(self, *responses):
|
|
57
|
+
"""A provider whose HTTP calls are answered by `responses`, in order."""
|
|
58
|
+
self.sent: list[dict] = []
|
|
59
|
+
queue = list(responses)
|
|
60
|
+
|
|
61
|
+
def handler(request: httpx2.Request) -> httpx2.Response:
|
|
62
|
+
self.sent.append(json.loads(request.content))
|
|
63
|
+
response = queue.pop(0)
|
|
64
|
+
if isinstance(response, Exception):
|
|
65
|
+
raise response
|
|
66
|
+
if isinstance(response, bytes):
|
|
67
|
+
return httpx2.Response(200, content=response, headers={"content-type": "text/event-stream"})
|
|
68
|
+
return response
|
|
69
|
+
|
|
70
|
+
return AnthropicProvider('test-key', 5, http_client=DefaultAsyncHttpxClient(
|
|
71
|
+
transport=httpx2.MockTransport(handler),
|
|
72
|
+
))
|
|
73
|
+
|
|
74
|
+
async def events(self, provider, request):
|
|
75
|
+
return [event async for event in provider.stream(request)]
|
|
76
|
+
|
|
77
|
+
def request(self, **overrides) -> ModelRequest:
|
|
78
|
+
fields = dict(
|
|
79
|
+
model='claude-sonnet-5-5', prefix=('How places work.', 'Be brief.'), tools=(OPEN,),
|
|
80
|
+
turns=(Turn('user', text='What is in notes?'),), max_output_tokens=4096, cache_key='gc://c',
|
|
81
|
+
)
|
|
82
|
+
return ModelRequest(**{**fields, **overrides})
|
|
83
|
+
|
|
84
|
+
async def test_a_request_becomes_the_wire_request_with_a_breakpoint_at_each_boundary(self):
|
|
85
|
+
provider = self.provider(recorded_reply())
|
|
86
|
+
history = (
|
|
87
|
+
Turn('user', text='What is in notes?'),
|
|
88
|
+
Turn('assistant', text='Looking.', calls=(ToolCall('toolu_0', 'open', {'at': '/notes'}),)),
|
|
89
|
+
Turn('user', results=(ToolResult('toolu_0', 'open', '# Notes'),
|
|
90
|
+
ToolResult('toolu_9', 'open', 'NotFound', is_error=True)), text='And tasks?'),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
await self.events(provider, self.request(turns=history, tool_choice='none'))
|
|
94
|
+
|
|
95
|
+
(sent,) = self.sent
|
|
96
|
+
self.assertEqual((sent['model'], sent['max_tokens'], sent['stream']), ('claude-sonnet-5-5', 4096, True))
|
|
97
|
+
self.assertEqual(sent['system'], [
|
|
98
|
+
{"type": "text", "text": "How places work."},
|
|
99
|
+
{"type": "text", "text": "Be brief.", "cache_control": {"type": "ephemeral"}},
|
|
100
|
+
])
|
|
101
|
+
self.assertEqual(sent['tools'], [
|
|
102
|
+
{"name": "open", "description": "Read a place.", "input_schema": OPEN.schema},
|
|
103
|
+
])
|
|
104
|
+
self.assertEqual(sent['tool_choice'], {"type": "none"})
|
|
105
|
+
self.assertEqual(sent['messages'], [
|
|
106
|
+
{"role": "user", "content": [{"type": "text", "text": "What is in notes?"}]},
|
|
107
|
+
{"role": "assistant", "content": [
|
|
108
|
+
{"type": "text", "text": "Looking."},
|
|
109
|
+
{"type": "tool_use", "id": "toolu_0", "name": "open", "input": {"at": "/notes"}},
|
|
110
|
+
]},
|
|
111
|
+
{"role": "user", "content": [
|
|
112
|
+
{"type": "tool_result", "tool_use_id": "toolu_0", "content": "# Notes"},
|
|
113
|
+
{"type": "tool_result", "tool_use_id": "toolu_9", "content": "NotFound", "is_error": True},
|
|
114
|
+
{"type": "text", "text": "And tasks?", "cache_control": {"type": "ephemeral"}},
|
|
115
|
+
]},
|
|
116
|
+
])
|
|
117
|
+
self.assertNotIn('thinking', sent)
|
|
118
|
+
self.assertNotIn('temperature', sent)
|
|
119
|
+
|
|
120
|
+
async def test_tool_choice_auto_is_left_to_the_api_default(self):
|
|
121
|
+
provider = self.provider(recorded_reply())
|
|
122
|
+
|
|
123
|
+
await self.events(provider, self.request())
|
|
124
|
+
|
|
125
|
+
self.assertNotIn('tool_choice', self.sent[0])
|
|
126
|
+
|
|
127
|
+
async def test_a_recorded_stream_becomes_text_whole_tool_calls_and_one_done(self):
|
|
128
|
+
events = await self.events(self.provider(recorded_reply()), self.request())
|
|
129
|
+
|
|
130
|
+
self.assertEqual(events[:3], [
|
|
131
|
+
TextDelta('Looking'), TextDelta(' now.'), ToolCall('toolu_1', 'open', {'at': '/notes'}),
|
|
132
|
+
])
|
|
133
|
+
(done,) = events[3:]
|
|
134
|
+
self.assertIsInstance(done, Done)
|
|
135
|
+
self.assertEqual(done.stop, 'tool_calls')
|
|
136
|
+
self.assertEqual(done.usage, Usage(input_tokens=442, output_tokens=25, cached_input_tokens=400))
|
|
137
|
+
self.assertEqual([block['type'] for block in done.provider_state['content']], ['thinking', 'text', 'tool_use'])
|
|
138
|
+
self.assertEqual(done.provider_state['content'][0]['signature'], 'sig-1')
|
|
139
|
+
json.dumps(done.provider_state)
|
|
140
|
+
|
|
141
|
+
async def test_stop_reasons_map_to_the_ports(self):
|
|
142
|
+
for vendor, port in (('end_turn', 'end'), ('max_tokens', 'max_tokens'), ('refusal', 'refusal')):
|
|
143
|
+
events = await self.events(self.provider(recorded_reply(vendor)), self.request())
|
|
144
|
+
self.assertEqual(events[-1].stop, port)
|
|
145
|
+
|
|
146
|
+
async def test_a_reply_goes_back_as_it_was_sent_thinking_included(self):
|
|
147
|
+
provider = self.provider(recorded_reply(), recorded_reply('end_turn'))
|
|
148
|
+
first = await self.events(provider, self.request())
|
|
149
|
+
reply = Turn('assistant', text='Looking now.', calls=(first[2],), provider_state=first[-1].provider_state)
|
|
150
|
+
results = Turn('user', results=(ToolResult('toolu_1', 'open', '# Notes'),))
|
|
151
|
+
|
|
152
|
+
await self.events(provider, self.request(turns=(Turn('user', text='Hi'), reply, results)))
|
|
153
|
+
|
|
154
|
+
replayed = self.sent[1]['messages'][1]['content']
|
|
155
|
+
self.assertEqual([block['type'] for block in replayed], ['thinking', 'text', 'tool_use'])
|
|
156
|
+
self.assertEqual(replayed[0]['signature'], 'sig-1')
|
|
157
|
+
self.assertEqual(replayed[2]['input'], {'at': '/notes'})
|
|
158
|
+
|
|
159
|
+
async def test_thinking_the_api_no_longer_accepts_is_dropped_and_the_call_sent_again(self):
|
|
160
|
+
unbound = error_response(
|
|
161
|
+
400, 'invalid_request_error',
|
|
162
|
+
'messages.1.content.0: Invalid `signature` in `thinking` block. The block is bound to a different '
|
|
163
|
+
'conversation. Remove the block.',
|
|
164
|
+
)
|
|
165
|
+
provider = self.provider(unbound, recorded_reply('end_turn'))
|
|
166
|
+
reply = Turn('assistant', text='Looking.', provider_state={'content': [
|
|
167
|
+
THINKING, {"type": "text", "text": "Looking."},
|
|
168
|
+
]})
|
|
169
|
+
|
|
170
|
+
events = await self.events(provider, self.request(turns=(
|
|
171
|
+
Turn('user', text='Hi'), reply, Turn('user', text='Go on'),
|
|
172
|
+
)))
|
|
173
|
+
|
|
174
|
+
self.assertEqual(events[-1].stop, 'end')
|
|
175
|
+
self.assertEqual(self.sent[0]['messages'][1]['content'][0]['type'], 'thinking')
|
|
176
|
+
self.assertEqual(self.sent[1]['messages'][1]['content'], [{"type": "text", "text": "Looking."}])
|
|
177
|
+
|
|
178
|
+
async def test_each_vendor_error_maps_to_its_code(self):
|
|
179
|
+
cases = [
|
|
180
|
+
(error_response(429, 'rate_limit_error'), 'rate_limit', True),
|
|
181
|
+
(error_response(529, 'overloaded_error'), 'overloaded', True),
|
|
182
|
+
(error_response(500, 'api_error'), 'server_error', True),
|
|
183
|
+
(error_response(503, 'api_error'), 'server_error', True),
|
|
184
|
+
(httpx2.ConnectError('refused'), 'connection', True),
|
|
185
|
+
(httpx2.ReadTimeout('silent'), 'timeout', True),
|
|
186
|
+
(error_response(401, 'authentication_error'), 'auth', False),
|
|
187
|
+
(error_response(403, 'permission_error'), 'auth', False),
|
|
188
|
+
(error_response(404, 'not_found_error'), 'unknown_model', False),
|
|
189
|
+
(error_response(400, 'invalid_request_error', 'prompt is too long: 300000 tokens > 200000 maximum'),
|
|
190
|
+
'context_overflow', False),
|
|
191
|
+
(error_response(413, 'request_too_large'), 'context_overflow', False),
|
|
192
|
+
(error_response(400, 'invalid_request_error', 'tools.0: bad schema'), 'invalid_request', False),
|
|
193
|
+
]
|
|
194
|
+
for response, code, retryable in cases:
|
|
195
|
+
with self.subTest(code=code, response=response):
|
|
196
|
+
with self.assertRaises(ProviderError) as raised:
|
|
197
|
+
await self.events(self.provider(response), self.request())
|
|
198
|
+
self.assertEqual((raised.exception.code, raised.exception.retryable), (code, retryable))
|
|
199
|
+
self.assertEqual(len(self.sent), 1)
|
|
200
|
+
|
|
201
|
+
async def test_an_error_event_inside_a_stream_is_retryable(self):
|
|
202
|
+
broken = sse(
|
|
203
|
+
{"type": "message_start", "message": {
|
|
204
|
+
"id": "msg_1", "type": "message", "role": "assistant", "model": "m", "content": [],
|
|
205
|
+
"stop_reason": None, "stop_sequence": None, "usage": {"input_tokens": 1, "output_tokens": 1},
|
|
206
|
+
}},
|
|
207
|
+
{"type": "error", "error": {"type": "overloaded_error", "message": "Overloaded"}},
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
with self.assertRaises(ProviderError) as raised:
|
|
211
|
+
await self.events(self.provider(broken), self.request())
|
|
212
|
+
|
|
213
|
+
self.assertEqual((raised.exception.code, raised.exception.retryable), ('overloaded', True))
|
|
214
|
+
|
|
215
|
+
async def test_a_stream_that_ends_without_its_reply_is_retryable(self):
|
|
216
|
+
cut = recorded_reply().split(b'event: message_delta')[0]
|
|
217
|
+
|
|
218
|
+
with self.assertRaises(ProviderError) as raised:
|
|
219
|
+
await self.events(self.provider(cut), self.request())
|
|
220
|
+
|
|
221
|
+
self.assertTrue(raised.exception.retryable)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
from django.test import override_settings
|
|
2
|
+
|
|
3
|
+
from graphcore.public.strategies import DeleteEntity
|
|
4
|
+
|
|
5
|
+
from agents.providers.fake import FakeProvider, calls, says
|
|
6
|
+
from agents.providers.port import ProviderError, ToolCall
|
|
7
|
+
from agents.runtime.compaction import SUMMARY_REQUEST
|
|
8
|
+
from agents.strategies.agents import UpdateAgent
|
|
9
|
+
from agents.strategies.instructions import UpdateInstruction
|
|
10
|
+
from agents.strategies.profiles import CustomizeAgent
|
|
11
|
+
from agents.tests.support import AgentsTestCase
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ContextTestCase(AgentsTestCase):
|
|
15
|
+
async def conversation(self, **fields):
|
|
16
|
+
carl = await self.create_user('carl')
|
|
17
|
+
agent_id = await self.create_agent(carl)
|
|
18
|
+
return carl, agent_id, await self.create_conversation(carl, agent_id, **fields)
|
|
19
|
+
|
|
20
|
+
async def context_messages(self, principal, conversation_id):
|
|
21
|
+
return [m for m in await self.messages(principal, conversation_id) if m.context_versions]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ContextTests(ContextTestCase):
|
|
25
|
+
async def test_a_turn_starts_by_saving_the_renders_of_its_context(self):
|
|
26
|
+
carl = await self.create_user('carl')
|
|
27
|
+
agent_id = await self.create_agent(carl)
|
|
28
|
+
standing = await self.create_instruction(carl, agent_id, name='House rules', text='No shouting.')
|
|
29
|
+
attached = await self.create_skill(carl, agent_id, name='research')
|
|
30
|
+
conversation_id = await self.create_conversation(carl, agent_id, context_ids=[standing])
|
|
31
|
+
|
|
32
|
+
await self.send(carl, conversation_id, 'Hello', context_ids=[attached])
|
|
33
|
+
|
|
34
|
+
roles = [role for role, _ in await self.transcript(carl, conversation_id)]
|
|
35
|
+
self.assertEqual(roles, ['user', 'system', 'assistant'])
|
|
36
|
+
(shown,) = await self.context_messages(carl, conversation_id)
|
|
37
|
+
self.assertEqual(set(shown.context_versions), {standing, attached})
|
|
38
|
+
self.assertLess(shown.content.index('No shouting.'), shown.content.index('Search first.'))
|
|
39
|
+
for entity_id, version in shown.context_versions.items():
|
|
40
|
+
self.assertIn(f"version: {version}", shown.content)
|
|
41
|
+
self.assertIn('No shouting.', shown.content)
|
|
42
|
+
(request,) = FakeProvider.requests
|
|
43
|
+
(turn,) = request.turns
|
|
44
|
+
self.assertTrue(turn.text.startswith('Hello'))
|
|
45
|
+
self.assertIn(shown.content, turn.text)
|
|
46
|
+
|
|
47
|
+
async def test_a_conversation_starts_looking_at_the_agents_start_address_and_only_then(self):
|
|
48
|
+
carl = await self.create_user('carl')
|
|
49
|
+
agent_id = await self.create_agent(carl, start_address='/agents')
|
|
50
|
+
conversation_id = await self.create_conversation(carl, agent_id)
|
|
51
|
+
|
|
52
|
+
await self.send(carl, conversation_id, 'One')
|
|
53
|
+
await self.create_agent(carl, name='Abed')
|
|
54
|
+
await self.send(carl, conversation_id, 'Two')
|
|
55
|
+
|
|
56
|
+
(shown,) = await self.context_messages(carl, conversation_id)
|
|
57
|
+
self.assertEqual(list(shown.context_versions), ['/agents'])
|
|
58
|
+
self.assertIn('Troy', shown.content)
|
|
59
|
+
self.assertNotIn('Abed', shown.content)
|
|
60
|
+
roles = [role for role, _ in await self.transcript(carl, conversation_id)]
|
|
61
|
+
self.assertEqual(roles, ['user', 'system', 'assistant', 'user', 'assistant'])
|
|
62
|
+
|
|
63
|
+
async def test_a_start_address_that_is_gone_is_named_as_left_out(self):
|
|
64
|
+
carl, agent_id, _ = await self.conversation()
|
|
65
|
+
rules = await self.create_instruction(carl, agent_id)
|
|
66
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, start_address=rules))
|
|
67
|
+
await self.run_strategy(carl, DeleteEntity.request_constructor(rules))
|
|
68
|
+
conversation_id = await self.create_conversation(carl, agent_id)
|
|
69
|
+
|
|
70
|
+
await self.send(carl, conversation_id, 'One')
|
|
71
|
+
|
|
72
|
+
(shown,) = await self.context_messages(carl, conversation_id)
|
|
73
|
+
self.assertEqual(shown.context_versions, {rules: None})
|
|
74
|
+
|
|
75
|
+
async def test_an_entity_is_rendered_again_only_after_it_changes(self):
|
|
76
|
+
carl, agent_id, _ = await self.conversation()
|
|
77
|
+
rules = await self.create_instruction(carl, agent_id, text='No shouting.')
|
|
78
|
+
other = await self.create_instruction(carl, agent_id, text='Be kind.')
|
|
79
|
+
conversation_id = await self.create_conversation(carl, agent_id, context_ids=[rules, other])
|
|
80
|
+
await self.send(carl, conversation_id, 'One')
|
|
81
|
+
|
|
82
|
+
await self.send(carl, conversation_id, 'Two')
|
|
83
|
+
self.assertEqual(len(await self.context_messages(carl, conversation_id)), 1)
|
|
84
|
+
|
|
85
|
+
await self.run_strategy(carl, UpdateInstruction.request_constructor(rules, text='Whisper.'))
|
|
86
|
+
await self.send(carl, conversation_id, 'Three')
|
|
87
|
+
|
|
88
|
+
first, second = await self.context_messages(carl, conversation_id)
|
|
89
|
+
self.assertEqual(list(second.context_versions), [rules])
|
|
90
|
+
self.assertNotEqual(second.context_versions[rules], first.context_versions[rules])
|
|
91
|
+
self.assertIn('Whisper.', second.content)
|
|
92
|
+
self.assertNotIn('Be kind.', second.content)
|
|
93
|
+
self.assertIn('No shouting.', first.content)
|
|
94
|
+
earlier = FakeProvider.requests[1].turns
|
|
95
|
+
self.assertEqual(FakeProvider.requests[2].turns[:len(earlier) - 1], earlier[:-1])
|
|
96
|
+
|
|
97
|
+
async def test_an_entity_the_sender_cannot_read_is_named_once_as_left_out(self):
|
|
98
|
+
carl, agent_id, _ = await self.conversation()
|
|
99
|
+
rules = await self.create_instruction(carl, agent_id)
|
|
100
|
+
conversation_id = await self.create_conversation(carl, agent_id, context_ids=[rules])
|
|
101
|
+
await self.run_strategy(carl, DeleteEntity.request_constructor(rules))
|
|
102
|
+
|
|
103
|
+
await self.send(carl, conversation_id, 'One')
|
|
104
|
+
await self.send(carl, conversation_id, 'Two')
|
|
105
|
+
|
|
106
|
+
(shown,) = await self.context_messages(carl, conversation_id)
|
|
107
|
+
self.assertEqual(shown.context_versions, {rules: None})
|
|
108
|
+
self.assertIn(f"{rules} is not readable to you and was left out.", shown.content)
|
|
109
|
+
|
|
110
|
+
async def test_a_change_during_the_turn_is_said_in_one_line_and_rendered_by_the_next_turn(self):
|
|
111
|
+
carl, agent_id, _ = await self.conversation()
|
|
112
|
+
rules = await self.create_instruction(carl, agent_id, text='No shouting.')
|
|
113
|
+
conversation_id = await self.create_conversation(carl, agent_id, context_ids=[rules])
|
|
114
|
+
FakeProvider.play(
|
|
115
|
+
calls(ToolCall('c1', 'call', {'at': rules, 'tool': 'update_instruction', 'params': {'text': 'Whisper.'}})),
|
|
116
|
+
calls(ToolCall('c2', 'open', {'at': '/'})),
|
|
117
|
+
says('Done.'),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
await self.send(carl, conversation_id, 'Change the rules')
|
|
121
|
+
|
|
122
|
+
transcript = await self.transcript(carl, conversation_id)
|
|
123
|
+
self.assertEqual([role for role, _ in transcript], ['user', 'system', 'assistant', 'system', 'assistant', 'assistant'])
|
|
124
|
+
self.assertRegex(transcript[3][1], r"^\S+ changed since it was shown to you; open it to read it\.$")
|
|
125
|
+
self.assertEqual(len(await self.context_messages(carl, conversation_id)), 1)
|
|
126
|
+
|
|
127
|
+
await self.send(carl, conversation_id, 'And now?')
|
|
128
|
+
|
|
129
|
+
self.assertIn('Whisper.', (await self.context_messages(carl, conversation_id))[-1].content)
|
|
130
|
+
|
|
131
|
+
async def test_an_unreadable_instruction_is_said_once_in_the_turn(self):
|
|
132
|
+
carl, agent_id, conversation_id = await self.conversation()
|
|
133
|
+
instruction_id = await self.create_instruction(carl, agent_id, attach=True)
|
|
134
|
+
await self.run_strategy(carl, DeleteEntity.request_constructor(instruction_id))
|
|
135
|
+
FakeProvider.play(calls(ToolCall('c1', 'open', {'at': '/'})), says('Done.'))
|
|
136
|
+
|
|
137
|
+
await self.send(carl, conversation_id, 'Hello')
|
|
138
|
+
|
|
139
|
+
notices = [text for role, text in await self.transcript(carl, conversation_id) if role == 'system']
|
|
140
|
+
self.assertEqual(
|
|
141
|
+
notices, [f"One instruction of this agent ({instruction_id}) is not readable to you and was left out."],
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class CompactionTests(ContextTestCase):
|
|
146
|
+
async def test_past_the_threshold_the_turn_summarizes_and_later_calls_send_the_summary(self):
|
|
147
|
+
carl, agent_id, _ = await self.conversation()
|
|
148
|
+
rules = await self.create_instruction(carl, agent_id, text='No shouting.')
|
|
149
|
+
conversation_id = await self.create_conversation(carl, agent_id, context_ids=[rules])
|
|
150
|
+
FakeProvider.play(says('First answer.', input_tokens=800))
|
|
151
|
+
await self.send(carl, conversation_id, 'First')
|
|
152
|
+
FakeProvider.play(says('Carl asked First and was answered.'), says('Second answer.'))
|
|
153
|
+
|
|
154
|
+
second = await self.send(carl, conversation_id, 'Second')
|
|
155
|
+
|
|
156
|
+
_, summarizing, answering = FakeProvider.requests
|
|
157
|
+
self.assertEqual(summarizing.tool_choice, 'none')
|
|
158
|
+
self.assertTrue(summarizing.turns[-1].text.endswith(SUMMARY_REQUEST))
|
|
159
|
+
(summary,) = [m for m in await self.messages(carl, conversation_id) if m.summary_through]
|
|
160
|
+
self.assertEqual((summary.summary_through, summary.content), (second, 'Carl asked First and was answered.'))
|
|
161
|
+
(turn,) = answering.turns
|
|
162
|
+
self.assertIn('Summary of the earlier conversation:\nCarl asked First and was answered.', turn.text)
|
|
163
|
+
self.assertIn('Second', turn.text)
|
|
164
|
+
self.assertNotIn('First answer.', turn.text)
|
|
165
|
+
self.assertIn('No shouting.', turn.text)
|
|
166
|
+
self.assertEqual(len(await self.context_messages(carl, conversation_id)), 2)
|
|
167
|
+
self.assertEqual(len(await self.messages(carl, conversation_id)), 7)
|
|
168
|
+
|
|
169
|
+
async def test_a_conversation_under_the_threshold_is_not_summarized(self):
|
|
170
|
+
carl, _, conversation_id = await self.conversation()
|
|
171
|
+
FakeProvider.play(says('First answer.', input_tokens=700))
|
|
172
|
+
await self.send(carl, conversation_id, 'First')
|
|
173
|
+
|
|
174
|
+
await self.send(carl, conversation_id, 'Second')
|
|
175
|
+
|
|
176
|
+
self.assertEqual(len(FakeProvider.requests), 2)
|
|
177
|
+
|
|
178
|
+
@override_settings(AGENTS_COMPACTION_THRESHOLD=0.5)
|
|
179
|
+
async def test_the_threshold_is_a_setting(self):
|
|
180
|
+
carl, _, conversation_id = await self.conversation()
|
|
181
|
+
FakeProvider.play(says('First answer.', input_tokens=600))
|
|
182
|
+
await self.send(carl, conversation_id, 'First')
|
|
183
|
+
|
|
184
|
+
await self.send(carl, conversation_id, 'Second')
|
|
185
|
+
|
|
186
|
+
self.assertEqual(len(FakeProvider.requests), 3)
|
|
187
|
+
|
|
188
|
+
async def test_an_agent_sets_its_own_threshold_and_a_profile_overrides_it(self):
|
|
189
|
+
carl, agent_id, conversation_id = await self.conversation()
|
|
190
|
+
await self.run_strategy(carl, UpdateAgent.request_constructor(agent_id, compaction_threshold=0.9))
|
|
191
|
+
FakeProvider.play(says('First answer.', input_tokens=800))
|
|
192
|
+
await self.send(carl, conversation_id, 'First')
|
|
193
|
+
|
|
194
|
+
FakeProvider.play(says('Second answer.', input_tokens=800))
|
|
195
|
+
await self.send(carl, conversation_id, 'Second')
|
|
196
|
+
self.assertEqual(len(FakeProvider.requests), 2)
|
|
197
|
+
|
|
198
|
+
await self.run_strategy(carl, CustomizeAgent.request_constructor(agent_id, compaction_threshold=0.5))
|
|
199
|
+
await self.send(carl, conversation_id, 'Third')
|
|
200
|
+
self.assertEqual(len(FakeProvider.requests), 4)
|
|
201
|
+
|
|
202
|
+
async def test_an_overflow_summarizes_the_older_half_and_calls_again(self):
|
|
203
|
+
carl, _, conversation_id = await self.conversation()
|
|
204
|
+
first = await self.send(carl, conversation_id, 'First')
|
|
205
|
+
overflow = ProviderError('context_overflow', 'too long', retryable=False)
|
|
206
|
+
FakeProvider.play([overflow], says('Carl asked First.'), says('Second answer.'))
|
|
207
|
+
|
|
208
|
+
await self.send(carl, conversation_id, 'Second')
|
|
209
|
+
|
|
210
|
+
messages = await self.messages(carl, conversation_id)
|
|
211
|
+
(summary,) = [m for m in messages if m.summary_through]
|
|
212
|
+
self.assertEqual(summary.summary_through, messages[1].entity_id)
|
|
213
|
+
self.assertNotEqual(summary.summary_through, first)
|
|
214
|
+
self.assertEqual(
|
|
215
|
+
[turn.text for turn in FakeProvider.requests[-1].turns],
|
|
216
|
+
['[From the runtime, not from the person]\nSummary of the earlier conversation:\nCarl asked First.'
|
|
217
|
+
'\n\nSecond'],
|
|
218
|
+
)
|
|
219
|
+
self.assertEqual((await self.turn_results(carl, conversation_id))[-1]['status'], 'completed')
|
|
220
|
+
|
|
221
|
+
async def test_a_second_overflow_fails_the_turn(self):
|
|
222
|
+
carl, _, conversation_id = await self.conversation()
|
|
223
|
+
await self.send(carl, conversation_id, 'First')
|
|
224
|
+
overflow = ProviderError('context_overflow', 'too long', retryable=False)
|
|
225
|
+
FakeProvider.play([overflow], says('Carl asked First.'), [overflow])
|
|
226
|
+
|
|
227
|
+
await self.send(carl, conversation_id, 'Second')
|
|
228
|
+
|
|
229
|
+
statuses = sorted(result['status'] for result in await self.turn_results(carl, conversation_id))
|
|
230
|
+
self.assertEqual(statuses, ['completed', 'error'])
|
|
231
|
+
self.assertIn('context_overflow', (await self.transcript(carl, conversation_id))[-1][1])
|