mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-30 10:52:15 +00:00
* chore: create learning subdirectory structure (routing, agents, intelligence) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: extract classify_query to routing/_utils.py Move the classify_query() function and its regex patterns into a shared utility module so multiple routing policies can import it without depending on the full trace_policy module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move routing files to learning/routing/ subdirectory Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: create LearnedRouterPolicy merging trace-driven + SFT routing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add conditional Algolia DocSearch integration Add Algolia DocSearch as an optional search upgrade — native lunr.js search remains the default until credentials are configured. Includes CDN assets, Jinja2 conditional config injection, init script with graceful fallback, light/dark theme CSS, improved search tokenization for snake_case/dotted identifiers, and search boosts for key pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move agent_evolver and skill_discovery to learning/agents/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move learning/orchestrator to learning/intelligence/orchestrator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: delete removed learning policies, rewrite __init__.py, clean up api_routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add SFT/GRPO/DSPy/GEPA config dataclasses, update LearningConfig Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add general-purpose SFT trainer (intelligence/sft_trainer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update stale imports in multi_model_router example Update imports to use new learning/routing/ paths after the subdirectory reorganization. Replace BanditRouterPolicy with LearnedRouterPolicy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add general-purpose GRPO trainer (intelligence/grpo_trainer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add DSPy agent optimizer (agents/dspy_optimizer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add GEPA agent optimizer (agents/gepa_optimizer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add learning-dspy and learning-gepa optional dependency extras Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update integration test to check for learned policy instead of grpo Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: clean up stale APIs and unused params in examples - deep_research: remove system_prompt and max_turns params not accepted by Jarvis.ask(), inline system prompt into the query instead - doc_qa: remove unused --top-k CLI arg that was never passed to the API - multi_model_router: fix select_model() call to match single-arg signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: import SFT/GRPO trainers in intelligence/__init__.py for registry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove .md file changes from PR Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: restore search boost frontmatter for key docs pages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
"""Tests for the GEPA agent optimizer (mocked -- no gepa dependency required)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
class TestGEPAOptimizerConfig:
|
|
def test_default_config(self) -> None:
|
|
from openjarvis.core.config import GEPAOptimizerConfig
|
|
|
|
cfg = GEPAOptimizerConfig()
|
|
assert cfg.max_metric_calls == 150
|
|
assert cfg.population_size == 10
|
|
assert cfg.min_traces == 20
|
|
|
|
def test_optimizer_init(self) -> None:
|
|
from openjarvis.core.config import GEPAOptimizerConfig
|
|
from openjarvis.learning.agents.gepa_optimizer import GEPAAgentOptimizer
|
|
|
|
cfg = GEPAOptimizerConfig()
|
|
optimizer = GEPAAgentOptimizer(cfg)
|
|
assert optimizer.config is cfg
|
|
|
|
|
|
class TestGEPAOptimizerOptimize:
|
|
def test_too_few_traces_skipped(self) -> None:
|
|
from openjarvis.core.config import GEPAOptimizerConfig
|
|
from openjarvis.learning.agents.gepa_optimizer import GEPAAgentOptimizer
|
|
|
|
optimizer = GEPAAgentOptimizer(GEPAOptimizerConfig(min_traces=10))
|
|
mock_store = MagicMock()
|
|
mock_store.list_traces.return_value = []
|
|
|
|
result = optimizer.optimize(mock_store)
|
|
assert result["status"] == "skipped"
|
|
|
|
def test_no_gepa_reports_error(self) -> None:
|
|
from openjarvis.core.config import GEPAOptimizerConfig
|
|
from openjarvis.core.types import StepType, Trace, TraceStep
|
|
from openjarvis.learning.agents.gepa_optimizer import GEPAAgentOptimizer
|
|
|
|
cfg = GEPAOptimizerConfig(min_traces=1)
|
|
optimizer = GEPAAgentOptimizer(cfg)
|
|
|
|
now = time.time()
|
|
traces = [Trace(
|
|
query="test", agent="native_react", model="qwen3:8b",
|
|
result="result", outcome="success", feedback=0.9,
|
|
started_at=now, ended_at=now + 1,
|
|
total_tokens=100, total_latency_seconds=1.0,
|
|
steps=[TraceStep(
|
|
step_type=StepType.GENERATE,
|
|
timestamp=now,
|
|
duration_seconds=0.5,
|
|
)],
|
|
)]
|
|
|
|
mock_store = MagicMock()
|
|
mock_store.list_traces.return_value = traces
|
|
|
|
# Ensure gepa is not available
|
|
with patch.dict("sys.modules", {"gepa": None}):
|
|
with patch(
|
|
"openjarvis.learning.agents.gepa_optimizer.HAS_GEPA",
|
|
False,
|
|
):
|
|
result = optimizer.optimize(mock_store)
|
|
assert result["status"] == "error"
|
|
assert "gepa" in result["reason"].lower()
|
|
|
|
|
|
class TestOpenJarvisGEPAAdapter:
|
|
def test_adapter_init(self) -> None:
|
|
from openjarvis.core.config import GEPAOptimizerConfig
|
|
from openjarvis.learning.agents.gepa_optimizer import (
|
|
OpenJarvisGEPAAdapter,
|
|
)
|
|
|
|
mock_store = MagicMock()
|
|
adapter = OpenJarvisGEPAAdapter(
|
|
mock_store, "native_react", GEPAOptimizerConfig(),
|
|
)
|
|
assert adapter.agent_name == "native_react"
|