feat(brain): API-Heuristik — Cross-Session-Counter fuer Skill-Drift
Variante B: scaffold-reflex Regel allein reicht nicht weil jede Chat- Anfrage eine eigene claude-CLI-Session ist. ARIA sieht in der aktuellen Session nicht dass sie gestern auch schon 10x dieselbe API gecurled hat. Beobachtung: 5+ Spotify-Bash-Calls hintereinander, kein Skill angelegt. Loesung: Brain trackt server-side aus dem persistierten agent_stream.jsonl. Bei jedem chat() wird der Log gescanned (cache 5min), Bash-curl-Calls nach Hostname aggregiert. Hosts mit >=3 Calls in 24h ohne passenden Skill landen als '## API-Heuristik'-Block im System-Prompt mit konkretem skill_scaffold-Vorschlag. Neue Module: - aria-brain/api_heuristic.py: - compute_hints(existing_skills, force): Aggregiert + filtert - build_section(hints): formatiert als kompakten Markdown-Block - Smart suggestions mapping (api.spotify.com → oauth-api template etc.) - Ignoriert interne Hosts (aria-brain, localhost, docker-bridge) - 5-min Cache damit nicht jeder Turn die JSONL parst - aria-brain/prompts.py: build_system_prompt nimmt api_heuristic_section als optionalen Block direkt nach Skills-Section. - aria-brain/agent.py: vor build_system_prompt Heuristik berechnen mit aktueller Skill-Liste, Block durchreichen. - 11. seed_rule scaffold-reflex umgeschrieben: kein 'in einer Session' mehr (das ergab keinen Sinn — jeder Turn neue Session). Stattdessen: '## API-Heuristik'-Block ist Dein Cross-Session-Gedaechtnis. Wenn da was steht: scaffolden BEVOR Du Bash machst. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
-1
@@ -879,6 +879,18 @@ class Agent:
|
||||
oauth_host = os.environ.get("RVS_HOST", "").strip()
|
||||
oauth_port = os.environ.get("RVS_PORT_PUBLIC", os.environ.get("RVS_PORT", "443")).strip()
|
||||
oauth_tls = os.environ.get("RVS_TLS", "true").strip().lower() != "false"
|
||||
|
||||
# API-Heuristik: wenn ARIA gegen externe APIs wiederholt via Bash
|
||||
# gecurled hat (cross-session, aus persistiertem agent_stream.jsonl),
|
||||
# injiziert das einen Hinweis-Block der ihr scaffolden empfiehlt.
|
||||
api_heuristic_section = ""
|
||||
try:
|
||||
import api_heuristic as _ah
|
||||
hints = _ah.compute_hints(existing_skills=all_skills)
|
||||
api_heuristic_section = _ah.build_section(hints)
|
||||
except Exception as exc:
|
||||
logger.warning("api_heuristic fehlgeschlagen: %s", exc)
|
||||
|
||||
system_prompt = build_system_prompt(hot, cold, skills=all_skills,
|
||||
triggers=all_triggers,
|
||||
condition_vars=condition_vars,
|
||||
@@ -887,7 +899,8 @@ class Agent:
|
||||
oauth_services=oauth_services,
|
||||
oauth_callback_host=oauth_host,
|
||||
oauth_callback_port=oauth_port,
|
||||
oauth_callback_tls=oauth_tls)
|
||||
oauth_callback_tls=oauth_tls,
|
||||
api_heuristic_section=api_heuristic_section)
|
||||
messages = [ProxyMessage(role="system", content=system_prompt)]
|
||||
for t in self.conversation.window():
|
||||
messages.append(ProxyMessage(role=t.role, content=t.content))
|
||||
|
||||
Reference in New Issue
Block a user