KI-Agent: Änderungen erscheinen in Live-Vorschau und PDF

- Dateien des Agenten werden sofort committet (die Vorschau liest in anderer Sitzung; vorher KeyError/unverändert)
- Beispielprotokoll der PDF-Vorschau gehört zum Arbeitsstand: neues Tool set_sample, run_prompt_test setzt das LLM-Ergebnis als Beispiel; im Vorschlag und bei der Freigabe übernommen
- Vorschau wechselt bei PDF-relevanten Änderungen automatisch auf die PDF-Ansicht
- Regressionstests inkl. echter SSE-/Freigabe-Strecke

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
RubenRWU
2026-10-15 16:46:32 +02:00
parent 9c352be05b
commit 40b3f687f7
6 changed files with 174 additions and 13 deletions

View File

@@ -47,7 +47,7 @@ def resolve_content(db: Session, t: Tenant, source: str) -> tuple[dict, dict]:
from app.agent.loop import WORKSPACES
if source[3:] not in WORKSPACES:
raise SourceGone("Der Arbeitsstand des Agenten ist nicht mehr im Speicher (Neustart?). Bitte „Entwurf“ wählen.")
cfg, files = WORKSPACES[source[3:]]
cfg, files, _sample = WORKSPACES[source[3:]]
return dict(cfg), dict(files)
if source.startswith("proposal:"):
from app.agent.loop import proposal_content
@@ -59,9 +59,22 @@ def resolve_content(db: Session, t: Tenant, source: str) -> tuple[dict, dict]:
return store.content(db, t, source)
def resolve_sample(db: Session, t: Tenant, source: str) -> str | None:
"""Beispielprotokoll-Override einer Agent-Quelle (None = das des Tenants)."""
if source.startswith("ws:"):
from app.agent.loop import WORKSPACES
w = WORKSPACES.get(source[3:])
return w[2] if w else None
if source.startswith("proposal:"):
from app.models import ChatMessage
m = db.get(ChatMessage, int(source[9:] or 0))
return (m.proposal or {}).get("sample") if m and m.tenant_id == t.id else None
return None
def run(db: Session, t: Tenant, source: str, kind: str, sample: str | None = None, args: dict | None = None) -> bytes | dict:
cfg, files = resolve_content(db, t, source)
return run_content(db, t, cfg, files, kind, sample, args)
return run_content(db, t, cfg, files, kind, sample if sample is not None else resolve_sample(db, t, source), args)
def run_content(db: Session, t: Tenant, cfg: dict, files: dict, kind: str, sample: str | None = None,