Bridge Coach memory brief with project metrics summaries.
Add Performance Summary block to memory brief, document metrics synthesis in agent-coach, and add e2e and CLI tests for qualitative plus quantitative briefs.
This commit is contained in:
@@ -11,7 +11,7 @@ from typing import List, Optional
|
||||
|
||||
from .registry import AgentRegistry, AgentCategory
|
||||
from .installer import AgentInstaller, ProjectInitializer, InstallationConfig
|
||||
from .metrics import MetricsStore, OptimizerStore
|
||||
from .metrics import MetricsStore, OptimizerStore, performance_summary_markdown
|
||||
from .optimization import OptimizationLoop, MIN_SAMPLES_FOR_RECOMMENDATIONS
|
||||
|
||||
|
||||
@@ -892,12 +892,21 @@ def memory_brief(agent_name: str, target: str, raw: bool):
|
||||
click.echo(f"Sources: {', '.join(sources) if sources else 'none'}")
|
||||
click.echo()
|
||||
|
||||
if not sources:
|
||||
metrics_store = MetricsStore(project_root, agent_name)
|
||||
metrics_summary = metrics_store.read_summary()
|
||||
if metrics_summary is None and metrics_store.executions_path.exists():
|
||||
metrics_summary = metrics_store.write_summary()
|
||||
|
||||
if not sources and not metrics_summary:
|
||||
click.echo("No agent memory files found in this project.")
|
||||
click.echo(f" Run: kaizen-agentic memory init {agent_name}")
|
||||
click.echo(" Then load the coach agent (agents/agent-coach.md) for synthesis.")
|
||||
return
|
||||
|
||||
performance_block = performance_summary_markdown(metrics_summary or {})
|
||||
if performance_block:
|
||||
click.echo(performance_block)
|
||||
|
||||
# Own memory section
|
||||
if own_memory:
|
||||
click.echo("### Your Memory")
|
||||
|
||||
@@ -21,6 +21,36 @@ def _parse_timestamp(value: str) -> datetime:
|
||||
return datetime.fromisoformat(normalized)
|
||||
|
||||
|
||||
_TREND_ARROWS = {"up": "↑", "down": "↓", "stable": "→", "unknown": "?"}
|
||||
|
||||
|
||||
def performance_summary_markdown(summary: Dict[str, Any]) -> str:
|
||||
"""Format ADR-004 summary.json as a Coach brief markdown section."""
|
||||
if not summary or summary.get("execution_count", 0) == 0:
|
||||
return ""
|
||||
|
||||
trend = summary.get("trend", {})
|
||||
success_trend = trend.get("success_rate", "unknown")
|
||||
quality_trend = trend.get("quality_score", "unknown")
|
||||
|
||||
lines = [
|
||||
"## Performance Summary",
|
||||
"",
|
||||
f"- Executions: {summary['execution_count']}",
|
||||
(
|
||||
f"- Success rate: {summary['success_rate']:.1%} "
|
||||
f"({_TREND_ARROWS.get(success_trend, '?')} {success_trend})"
|
||||
),
|
||||
f"- Avg quality: {summary['avg_quality_score']:.2f} "
|
||||
f"({_TREND_ARROWS.get(quality_trend, '?')} {quality_trend})",
|
||||
f"- Avg execution time: {summary['avg_execution_time_s']:.1f}s",
|
||||
]
|
||||
if summary.get("last_execution"):
|
||||
lines.append(f"- Last execution: {summary['last_execution']}")
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _trend_direction(recent: List[float], prior: List[float]) -> str:
|
||||
if not recent:
|
||||
return "unknown"
|
||||
|
||||
Reference in New Issue
Block a user