mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-15 19:32:21 +02:00
feat(harness): authority, turn contract, tools, clean_agent_preview
Chat/agent harness work: request-authority model, turn contract, tool
policy/parsing/execution, clean_agent_preview streaming/thinking, ask_user
persistence, session probes, and scheduler.
Source: vendor/photocraft (ad1cff44) harness files, 3-way merged onto
upstream/dev (a8c147b2). Harness core files were independently developed
in both lineages; resolution policy documented in pr_work/C_conflicts.md
(vendor kept where ahead, upstream kept where vendor is behind; full delta
preserved in pr_work/C_upstream_delta.patch).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a8c147b238
commit
364229f2dc
@@ -17,6 +17,42 @@ ERROR = 'event: error\ndata: {"status": 504, "error": {"message": "stream timeou
|
||||
DONE = 'data: [DONE]\n\n'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_answer_deltas_are_visible_before_terminal_completion_check():
|
||||
finish = asyncio.Event()
|
||||
|
||||
@with_completion_gate
|
||||
async def stream(messages):
|
||||
yield _event({'delta': 'Live answer starts. '})
|
||||
await finish.wait()
|
||||
yield _event({'type': 'metrics', 'data': {}})
|
||||
yield DONE
|
||||
|
||||
output = stream([])
|
||||
first = await asyncio.wait_for(anext(output), timeout=0.2)
|
||||
assert json.loads(first[6:])['delta'] == 'Live answer starts. '
|
||||
finish.set()
|
||||
remaining = [chunk async for chunk in output]
|
||||
assert _decision([first, *remaining])['can_complete'] is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_completion_replacement_replaces_already_streamed_answer_for_turn():
|
||||
@with_completion_gate
|
||||
async def stream(messages):
|
||||
yield _event({'delta': 'The function returns a boolean. I ran pytest and all tests passed.'})
|
||||
yield _event({'type': 'metrics', 'data': {}})
|
||||
yield DONE
|
||||
|
||||
chunks = [chunk async for chunk in stream([{'role': 'user', 'content': 'Explain this code.'}])]
|
||||
frames = [data for event, data in _frames(chunks) if event == 'message' and isinstance(data, dict)]
|
||||
assert any(item.get('delta') == 'The function returns a boolean.' for item in frames)
|
||||
assert not any('I ran pytest' in str(item.get('delta', '')) for item in frames)
|
||||
replacement = next(item for item in frames if item.get('type') == 'final_response')
|
||||
assert 'I ran pytest' not in replacement['content']
|
||||
assert replacement['replacement_scope'] == 'turn'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize('terminal_texts', [[], ['', ''], ['Recovered answer with literal [DONE] text.']])
|
||||
async def test_terminal_round_retraction_does_not_resurrect_buffered_drafts(terminal_texts):
|
||||
|
||||
Reference in New Issue
Block a user