The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): probe Markdown ingestion and generated completion delivery
Teknium5db3d4b6bdb2
diff --git a/evals/desktop_bug_campaign/markdown-README.md b/evals/desktop_bug_campaign/markdown-README.mdnew file mode 100644index 00000000000..59fe9499afb--- /dev/null+++ b/evals/desktop_bug_campaign/markdown-README.md@@ -0,0 +1,26 @@+# Markdown rendering probe++This uses the production Desktop components in a real Chromium renderer, without+starting an agent or making a model request. It is not a native Electron/backend+transport E2E test.++From the worktree root, with the campaign's locked dependencies and Xvfb ready:++```sh+.venv/bin/python evals/desktop_bug_campaign/markdown-producer.py /home/teknium/.hermes/cache/desktop-bugs-74848ed3/navigation-markdown/producer.json+node evals/desktop_bug_campaign/navigation-vite.mjs+# In another terminal:+DISPLAY=:208 PLAYWRIGHT_BROWSERS_PATH=/home/teknium/.hermes/cache/desktop-bugs-74848ed3/navigation-markdown/browsers node evals/desktop_bug_campaign/navigation-markdown-live.mjs after+```++The producer isolates both HOME and HERMES_HOME, saves a deterministic report via+`save_job_output`, formats it through the cron completion and process-notification+producers, persists an actual delivery row, and reads it back from SQLite. It does+not execute the scheduled job. The browser feeds that row through hydration,+runtime conversion, and `SystemMessage`, independently of the assistant Markdown+samples. JSON receipts and screenshots go to the campaign artifact directory.++The browser is a receipt collector: compare `hardBr`, `softBr`, `breaks`, `outputs`,+`errors`, and `producer.dom`. Hard-break samples should emit a `br`; the soft-break+control should not. The separate async report loss (#101078) is not repaired by+the whitespace fix (#97117).diff --git a/evals/desktop_bug_campaign/markdown-producer.py b/evals/desktop_bug_campaign/markdown-producer.pynew file mode 100644index 00000000000..e960450ae81--- /dev/null+++ b/evals/desktop_bug_campaign/markdown-producer.py@@ -0,0 +1,43 @@+"""Collect real cron completion producer + durable delivery, without inference."""+import asyncio+import json+import os+from pathlib import Path+import sys+import tempfile+import time++repo = Path(__file__).resolve().parents[2]+sys.path.insert(0, str(repo))+output = Path(sys.argv[1])+with tempfile.TemporaryDirectory(prefix="markdown-producer-") as temporary:+ home = Path(temporary)+ for key in list(os.environ):+ if key.startswith("HERMES_") or key.endswith(("_API_KEY", "_TOKEN")):+ os.environ.pop(key, None)+ os.environ.update(HOME=str(home), HERMES_HOME=str(home / ".hermes"))+ from cron.jobs import create_job, save_job_output+ from gateway.wake import persist_delegation_delivery+ from hermes_state import SessionDB+ from tools.cronjob_tools import _manual_run_completion+ from tools.process_registry_notifications import format_process_notification++ report = "# Generated inspection\n\n**Conclusion:** attention needed.\n\n| Strategy | Status |\n|---|---|\n| Canary | running |\n\nFirst line \nSecond line\n\n```python\nvalue = 1 \nvalue = 2 \n```"+ job = create_job(prompt="Offline fixture; never run", schedule="0 0 * * *", name="Markdown probe", deliver="local")+ save_job_output(job["id"], report)+ result = _manual_run_completion({"success": True}, job["id"], job["name"], "local", time.time())+ event = dict(result, type="async_delegation", delegation_id="markdown-probe", goal="Inspect a generated report")+ envelope = format_process_notification(event)+ assert envelope is not None+ db = SessionDB(db_path=home / "delivery.db")+ db.create_session(session_id="markdown-probe", source="desktop")++ class DeliveryStore:+ def _ensure_session_db(self):+ return db++ asyncio.run(persist_delegation_delivery(DeliveryStore(), text=envelope, session_id="markdown-probe", evt=event))+ rows = db.get_messages_as_conversation("markdown-probe", include_row_ids=True)+ output.write_text(json.dumps({"report": report, "result": result, "envelope": envelope, "rows": rows}, indent=2), encoding="utf-8")+ print(json.dumps({"producer": "save_job_output -> _manual_run_completion -> format_process_notification -> persist_delegation_delivery -> SessionDB readback", "rows": len(rows), "report_preserved": report in rows[0]["content"], "display_kind": rows[0].get("display_kind"), "model_requests": 0}))+ db.close()diff --git a/evals/desktop_bug_campaign/navigation-markdown-live.mjs b/evals/desktop_bug_campaign/navigation-markdown-live.mjsindex 14fe96984d4..1b9443188c7 100644--- a/evals/desktop_bug_campaign/navigation-markdown-live.mjs+++ b/evals/desktop_bug_campaign/navigation-markdown-live.mjs@@ -1,5 +1,6 @@import { chromium } from '../../node_modules/playwright/index.mjs'import fs from 'node:fs'+import { execFileSync } from 'node:child_process'const a='/home/teknium/.hermes/cache/desktop-bugs-74848ed3/navigation-markdown'const tag=process.argv[2]??'before'const browser=await chromium.launch({headless:false,args:['--no-sandbox']})@@ -9,8 +10,14 @@ await page.goto('http://127.0.0.1:18160/navigation-markdown-probe.html',{waitUntawait page.waitForSelector('#hard p',{timeout:90000})await page.waitForTimeout(6000)await page.waitForSelector('#hard p',{timeout:90000})-const result=await page.evaluate(()=>({inputs:window.probeInputs,outputs:window.probeOutputs,hardBr:document.querySelectorAll('#hard br').length,softBr:document.querySelectorAll('#soft br').length,text:document.body.innerText,html:document.querySelector('main').innerHTML}))+const result=await page.evaluate(()=>({inputs:window.probeInputs,outputs:window.probeOutputs,ingress:window.ingress,hardBr:document.querySelectorAll('#hard br').length,softBr:document.querySelectorAll('#soft br').length,breaks:Object.fromEntries(Object.keys(window.ingress).map(k=>[k,document.querySelectorAll(`#${k} br`).length])),text:document.body.innerText,html:document.querySelector('main').innerHTML}))+const producer = JSON.parse(fs.readFileSync(`${a}/producer.json`, 'utf8'))+result.producer = await page.evaluate(rows => window.renderProducer(rows), producer.rows)+await page.waitForSelector('#producer [data-role="system"]')+result.producer.dom = await page.locator('#producer').evaluate(el=>({text:el.textContent,headings:el.querySelectorAll('h1').length,tables:el.querySelectorAll('table').length,html:el.innerHTML}))result.errors=errors+result.sourceSha=execFileSync('git', ['rev-parse', 'HEAD'], {encoding:'utf8'}).trim()+result.codeText=await page.locator('#code code').textContent()await page.screenshot({path:`${a}/markdown-${tag}.png`,fullPage:true})fs.writeFileSync(`${a}/markdown-${tag}.json`,JSON.stringify(result,null,2));console.log(JSON.stringify(result,null,2))await browser.close()diff --git a/evals/desktop_bug_campaign/navigation-markdown-probe.tsx b/evals/desktop_bug_campaign/navigation-markdown-probe.tsxindex ab7b27746b3..8c5721c6e1d 100644--- a/evals/desktop_bug_campaign/navigation-markdown-probe.tsx+++ b/evals/desktop_bug_campaign/navigation-markdown-probe.tsx@@ -1,13 +1,47 @@import { createRoot } from 'react-dom/client'+import { AssistantRuntimeProvider, ThreadPrimitive, useExternalStoreRuntime, type ThreadMessage } from '@assistant-ui/react'+import type { ReactNode } from 'react'+import type { SessionMessage } from '@/types/hermes'import { QueryClientProvider } from '@tanstack/react-query'import { queryClient } from '@/lib/query-client'import { I18nProvider } from '@/i18n'import { ThemeProvider } from '@/themes/context'import { RootTooltipProvider } from '@/components/ui/tooltip'import { MarkdownTextContent } from '@/components/assistant-ui/markdown-text'+import { SystemMessage } from '@/components/assistant-ui/thread/system-message'import { preprocessMarkdown } from '@/lib/markdown-preprocess'+import { toChatMessages } from '@/lib/chat-messages/hydration'+import { toRuntimeMessage } from '@/lib/chat-runtime'+import { assistantTextPart, renderMediaTags } from '@/lib/chat-messages/parts'+import { stripGeneratedImageEchoes } from '@/lib/generated-images'+import { extractEmbeddedImages } from '@/lib/embedded-images'+import { stripPreviewTargets } from '@/lib/preview-targets'const hard = 'First line \nSecond line'const soft = 'Soft first\nSoft second'const code = '```python\nvalue = 1 \nvalue = 2 \n```'-Object.assign(window, {probeInputs:{hard,soft,code}, probeOutputs:{hard:preprocessMarkdown(hard),soft:preprocessMarkdown(soft),code:preprocessMarkdown(code)}})-createRoot(document.getElementById('root')!).render(<QueryClientProvider client={queryClient}><I18nProvider><ThemeProvider><RootTooltipProvider><main style={{padding:40}}><h1>Production Markdown renderer probe</h1>{Object.entries({hard,soft,code}).map(([id,text])=><section id={id} key={id}><h2>{id}</h2><MarkdownTextContent text={text} isRunning={false}/></section>)}</main></RootTooltipProvider></ThemeProvider></I18nProvider></QueryClientProvider>)+const corpus = hard + '\n\n' + code+const image = 'data:image/png;base64,' + 'A'.repeat(64)+const assistant = assistantTextPart(corpus)+const ingress = {+ assistant: assistant.type === 'text' ? assistant.text : '',+ media: renderMediaTags(corpus + '\n\nMEDIA: /tmp/image.png'),+ preview: stripPreviewTargets(corpus + '\n\n[Preview: x](#preview:test)'),+ embedded: extractEmbeddedImages(corpus + '\n\n' + image).cleanedText,+ generated: stripGeneratedImageEchoes(corpus + '\n\n', ['/tmp/image.png'])+}+Object.assign(window, {probeInputs:{hard,soft,code}, probeOutputs:{hard:preprocessMarkdown(hard),soft:preprocessMarkdown(soft),code:preprocessMarkdown(code)}, ingress})+function Providers({children}: {children: ReactNode}) {+ return <QueryClientProvider client={queryClient}><I18nProvider><ThemeProvider><RootTooltipProvider>{children}</RootTooltipProvider></ThemeProvider></I18nProvider></QueryClientProvider>+}+function Delivery({messages}: {messages: ThreadMessage[]}) {+ const runtime = useExternalStoreRuntime<ThreadMessage>({messages, isRunning:false, onNew:async()=>{}})+ return <AssistantRuntimeProvider runtime={runtime}><ThreadPrimitive.Root><ThreadPrimitive.Messages components={{Message: SystemMessage}}/></ThreadPrimitive.Root></AssistantRuntimeProvider>+}+Object.assign(window, {renderProducer(rows: SessionMessage[]) {+ const hydrated = toChatMessages(rows)+ const runtime = hydrated.map(toRuntimeMessage)+ const mount = document.createElement('section'); mount.id = 'producer'; document.body.append(mount)+ createRoot(mount).render(<Providers><Delivery messages={runtime}/></Providers>)+ return {hydrated,runtime}+}})+createRoot(document.getElementById('root')!).render(<Providers><main style={{padding:40}}><h1>Production Markdown renderer probe</h1>{Object.entries({hard,soft,code,...ingress}).map(([id,text])=><section id={id} key={id}><h2>{id}</h2><MarkdownTextContent text={text} isRunning={false}/></section>)}</main></Providers>)