evoloop-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evoloop_cli/__init__.py +3 -0
- evoloop_cli/__main__.py +10 -0
- evoloop_cli/_skills/evoloop-constitution/SKILL.md +59 -0
- evoloop_cli/_skills/evoloop-constitution/references/writing-guide.md +89 -0
- evoloop_cli/_skills/evoloop-constitution/templates/config.yaml +52 -0
- evoloop_cli/_skills/evoloop-constitution/templates/constitution.md +39 -0
- evoloop_cli/_skills/evoloop-evaluate/SKILL.md +85 -0
- evoloop_cli/_skills/evoloop-evaluate/schemas/parsed_report.schema.json +170 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_junit_report.py +311 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_pytest_report.py +276 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_report.py +101 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/update_eval_index.py +111 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/validate_parsed_report.py +178 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/analysis.md +51 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/progress.md +42 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/tasks.md +34 -0
- evoloop_cli/_skills/evoloop-evolve/SKILL.md +76 -0
- evoloop_cli/_skills/evoloop-evolve/scripts/evolve_state.py +333 -0
- evoloop_cli/_skills/evoloop-implement/SKILL.md +57 -0
- evoloop_cli/_skills/evoloop-implement/scripts/check_scope.py +154 -0
- evoloop_cli/_skills/evoloop-implement/scripts/commit_section.py +78 -0
- evoloop_cli/_skills/evoloop-init/SKILL.md +95 -0
- evoloop_cli/_skills/evoloop-init/scripts/scaffold_evals.py +546 -0
- evoloop_cli/_skills/evoloop-init/templates/common/evals/datasets/domain_flows.yaml +33 -0
- evoloop_cli/_skills/evoloop-init/templates/common/evaluations/README.md +9 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgentAdapter.java +13 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +71 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/DeterministicEvaluators.java +174 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +45 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/FlowRunResult.java +25 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/__init__.py +1 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/adapter.py +63 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/deepagents_adapter.py +223 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/__init__.py +1 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/deterministic.py +234 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/llm_judge.py +189 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/fakes.py +26 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/harness.py +100 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/conftest.py +38 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/test_agentic_flows.py +36 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/test_eval_framework.py +175 -0
- evoloop_cli/_skills/evoloop-new/SKILL.md +125 -0
- evoloop_cli/_skills/evoloop-new/scripts/scaffold_agent.py +911 -0
- evoloop_cli/_skills/evoloop-new/templates/common/.evoloop/constitution.md +34 -0
- evoloop_cli/_skills/evoloop-new/templates/common/.gitignore +22 -0
- evoloop_cli/_skills/evoloop-new/templates/common/AGENTS.md +17 -0
- evoloop_cli/_skills/evoloop-new/templates/common/README.md +83 -0
- evoloop_cli/_skills/evoloop-new/templates/common/skills/__DOMAIN__/SKILL.md +21 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +113 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +85 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/Fake__DOMAIN_PASCAL__Client.java +37 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/OpenAiCompatibleRunner.java +433 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +125 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +163 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +18 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/Application.java +15 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +167 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +41 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Factory.java +32 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +20 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/resources/application.yml +17 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/Application.java +17 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +159 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Config.java +32 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +40 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +25 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/resources/application.yml +19 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_custom.gradle +33 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_langchain4j.gradle +40 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_micronaut.gradle +52 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_spring-ai.gradle +45 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/settings.gradle +1 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_custom.xml +57 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_langchain4j.xml +87 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_micronaut.xml +101 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_spring-ai.xml +61 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/ConversationMemory.java +36 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/Default__DOMAIN_PASCAL__Client.java +9 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/DomainRecord.java +10 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/TurnOutcome.java +15 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Client.java +8 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/fakes.py +22 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_custom.py +186 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_deepagents.py +100 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/tests/test_eval_framework.py +196 -0
- evoloop_cli/_skills/evoloop-new/templates/python/pyproject.toml +18 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__init__.py +13 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__main__.py +6 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_custom.py +209 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_deepagents.py +61 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/cli.py +71 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/client.py +31 -0
- evoloop_cli/_skills/evoloop-scenarios/SKILL.md +49 -0
- evoloop_cli/_skills/evoloop-scenarios/scripts/validate_scenarios.py +261 -0
- evoloop_cli/_skills/evoloop-scenarios/templates/scenario_schema.md +49 -0
- evoloop_cli/cli.py +331 -0
- evoloop_cli-0.1.0.dist-info/METADATA +214 -0
- evoloop_cli-0.1.0.dist-info/RECORD +103 -0
- evoloop_cli-0.1.0.dist-info/WHEEL +4 -0
- evoloop_cli-0.1.0.dist-info/entry_points.txt +2 -0
- evoloop_cli-0.1.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Framework-agnostic, checkpointer-backed OpenAI-compatible agent for __DOMAIN_TITLE__."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import urllib.error
|
|
8
|
+
import urllib.request
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from .client import __DOMAIN_PASCAL__Client
|
|
14
|
+
|
|
15
|
+
DEFAULT_LLM_BASE_URL = "http://localhost:8080/v1"
|
|
16
|
+
DEFAULT_LLM_MODEL = "local-model"
|
|
17
|
+
|
|
18
|
+
# Keep SYSTEM_PROMPT compact (<= 120 words) and refactor rather than append patches.
|
|
19
|
+
SYSTEM_PROMPT = (
|
|
20
|
+
"You are a helpful __DOMAIN_TITLE__ assistant. Follow AGENTS.md strictly. "
|
|
21
|
+
"Ground every factual statement in domain tool outputs and never fabricate data. "
|
|
22
|
+
"If a request is vague or missing required identifiers, ask one clear clarifying question without calling tools. "
|
|
23
|
+
"If a tool returns an error, reply briefly and honestly without guessing missing values. "
|
|
24
|
+
"Politely decline requests outside the __DOMAIN__ domain."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class ConversationStateStore:
|
|
30
|
+
"""In-memory thread-scoped checkpointer for deterministic multi-turn state persistence."""
|
|
31
|
+
|
|
32
|
+
threads: dict[str, list[dict[str, Any]]] = field(default_factory=dict)
|
|
33
|
+
|
|
34
|
+
def get_messages(self, thread_id: str) -> list[dict[str, Any]]:
|
|
35
|
+
return list(self.threads.get(thread_id, []))
|
|
36
|
+
|
|
37
|
+
def append_messages(self, thread_id: str, messages: list[dict[str, Any]]) -> None:
|
|
38
|
+
self.threads.setdefault(thread_id, []).extend(messages)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def create___DOMAIN___tools(client: __DOMAIN_PASCAL__Client) -> dict[str, Callable[[str], str]]:
|
|
42
|
+
"""Bind domain tool functions to an injected __DOMAIN_PASCAL__Client implementation."""
|
|
43
|
+
__PYTHON_CUSTOM_TOOLS__
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
ChatTransport = Callable[[dict[str, Any]], dict[str, Any]]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class __DOMAIN_PASCAL__Agent:
|
|
51
|
+
"""Minimal runnable OpenAI-compatible tool-calling agent with checkpointer persistence."""
|
|
52
|
+
|
|
53
|
+
client: __DOMAIN_PASCAL__Client
|
|
54
|
+
tools: dict[str, Callable[[str], str]]
|
|
55
|
+
system_prompt: str = SYSTEM_PROMPT
|
|
56
|
+
base_url: str = DEFAULT_LLM_BASE_URL
|
|
57
|
+
model: str = DEFAULT_LLM_MODEL
|
|
58
|
+
api_key: str = "not-needed"
|
|
59
|
+
checkpointer: ConversationStateStore = field(default_factory=ConversationStateStore)
|
|
60
|
+
transport: ChatTransport | None = None
|
|
61
|
+
max_tool_rounds: int = 4
|
|
62
|
+
|
|
63
|
+
def _tool_schemas(self) -> list[dict[str, Any]]:
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
"type": "function",
|
|
67
|
+
"function": {
|
|
68
|
+
"name": name,
|
|
69
|
+
"description": f"Run {name.replace('_', ' ')} for a concrete query identifier.",
|
|
70
|
+
"parameters": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {
|
|
73
|
+
"query": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "Concrete identifier or query string.",
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"required": ["query"],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
for name in self.tools
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
def _post_chat_completions(self, payload: dict[str, Any]) -> dict[str, Any]:
|
|
86
|
+
if self.transport is not None:
|
|
87
|
+
return self.transport(payload)
|
|
88
|
+
url = f"{self.base_url.rstrip('/')}/chat/completions"
|
|
89
|
+
req = urllib.request.Request(
|
|
90
|
+
url,
|
|
91
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
92
|
+
headers={
|
|
93
|
+
"Content-Type": "application/json",
|
|
94
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
95
|
+
},
|
|
96
|
+
method="POST",
|
|
97
|
+
)
|
|
98
|
+
try:
|
|
99
|
+
with urllib.request.urlopen(req, timeout=60) as resp:
|
|
100
|
+
return json.loads(resp.read().decode("utf-8"))
|
|
101
|
+
except urllib.error.URLError as exc:
|
|
102
|
+
raise RuntimeError(f"LLM endpoint unreachable at {url}: {exc}") from exc
|
|
103
|
+
|
|
104
|
+
def invoke_tool(self, tool_name: str, query: str) -> str:
|
|
105
|
+
"""Execute a bound domain tool with uniform error handling."""
|
|
106
|
+
if tool_name not in self.tools:
|
|
107
|
+
return f"Error: Unknown tool '{tool_name}'."
|
|
108
|
+
return self.tools[tool_name](query)
|
|
109
|
+
|
|
110
|
+
def record_turn(self, thread_id: str, user_input: str, assistant_reply: str) -> list[dict[str, Any]]:
|
|
111
|
+
"""Persist a user/assistant turn in the configured checkpointer."""
|
|
112
|
+
turn_messages = [
|
|
113
|
+
{"role": "user", "content": user_input},
|
|
114
|
+
{"role": "assistant", "content": assistant_reply},
|
|
115
|
+
]
|
|
116
|
+
self.checkpointer.append_messages(thread_id, turn_messages)
|
|
117
|
+
return self.checkpointer.get_messages(thread_id)
|
|
118
|
+
|
|
119
|
+
def run_turn(self, user_input: str, *, thread_id: str = "default") -> dict[str, Any]:
|
|
120
|
+
"""Execute one conversational turn with OpenAI-compatible tool calling and state persistence."""
|
|
121
|
+
history = self.checkpointer.get_messages(thread_id)
|
|
122
|
+
messages: list[dict[str, Any]] = [{"role": "system", "content": self.system_prompt}, *history]
|
|
123
|
+
new_messages: list[dict[str, Any]] = [{"role": "user", "content": user_input}]
|
|
124
|
+
messages.append(new_messages[0])
|
|
125
|
+
|
|
126
|
+
captured_calls: list[dict[str, Any]] = []
|
|
127
|
+
final_response = ""
|
|
128
|
+
|
|
129
|
+
for _ in range(self.max_tool_rounds + 1):
|
|
130
|
+
payload = {
|
|
131
|
+
"model": self.model,
|
|
132
|
+
"temperature": 0,
|
|
133
|
+
"messages": messages,
|
|
134
|
+
"tools": self._tool_schemas(),
|
|
135
|
+
}
|
|
136
|
+
data = self._post_chat_completions(payload)
|
|
137
|
+
choice = (data.get("choices") or [{}])[0]
|
|
138
|
+
msg = choice.get("message") or {}
|
|
139
|
+
tool_calls = msg.get("tool_calls") or []
|
|
140
|
+
|
|
141
|
+
if tool_calls:
|
|
142
|
+
assistant_msg = {
|
|
143
|
+
"role": "assistant",
|
|
144
|
+
"content": msg.get("content") or "",
|
|
145
|
+
"tool_calls": tool_calls,
|
|
146
|
+
}
|
|
147
|
+
messages.append(assistant_msg)
|
|
148
|
+
new_messages.append(assistant_msg)
|
|
149
|
+
|
|
150
|
+
for tc in tool_calls:
|
|
151
|
+
fn = tc.get("function") or {}
|
|
152
|
+
name = str(fn.get("name") or "")
|
|
153
|
+
raw_args = fn.get("arguments") or "{}"
|
|
154
|
+
try:
|
|
155
|
+
parsed_args = json.loads(raw_args) if isinstance(raw_args, str) else dict(raw_args)
|
|
156
|
+
except json.JSONDecodeError:
|
|
157
|
+
parsed_args = {}
|
|
158
|
+
query = str(parsed_args.get("query", ""))
|
|
159
|
+
captured_calls.append({"name": name, "args": parsed_args})
|
|
160
|
+
tool_output = self.invoke_tool(name, query)
|
|
161
|
+
tool_msg = {
|
|
162
|
+
"role": "tool",
|
|
163
|
+
"tool_call_id": str(tc.get("id") or f"call_{len(captured_calls)}"),
|
|
164
|
+
"name": name,
|
|
165
|
+
"content": tool_output,
|
|
166
|
+
}
|
|
167
|
+
messages.append(tool_msg)
|
|
168
|
+
new_messages.append(tool_msg)
|
|
169
|
+
continue
|
|
170
|
+
|
|
171
|
+
final_response = str(msg.get("content") or "").strip()
|
|
172
|
+
reply_msg = {"role": "assistant", "content": final_response}
|
|
173
|
+
messages.append(reply_msg)
|
|
174
|
+
new_messages.append(reply_msg)
|
|
175
|
+
break
|
|
176
|
+
|
|
177
|
+
self.checkpointer.append_messages(thread_id, new_messages)
|
|
178
|
+
return {
|
|
179
|
+
"final_response": final_response,
|
|
180
|
+
"tool_calls": captured_calls,
|
|
181
|
+
"messages": new_messages,
|
|
182
|
+
"skill_loaded": False,
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async def arun_turn(self, user_input: str, *, thread_id: str = "default") -> dict[str, Any]:
|
|
186
|
+
"""Async wrapper around run_turn() for evaluation adapters."""
|
|
187
|
+
return self.run_turn(user_input, thread_id=thread_id)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def create___DOMAIN___agent(
|
|
191
|
+
client: __DOMAIN_PASCAL__Client,
|
|
192
|
+
*,
|
|
193
|
+
base_url: str | None = None,
|
|
194
|
+
model: str | None = None,
|
|
195
|
+
api_key: str | None = None,
|
|
196
|
+
checkpointer: ConversationStateStore | None = None,
|
|
197
|
+
transport: ChatTransport | None = None,
|
|
198
|
+
) -> __DOMAIN_PASCAL__Agent:
|
|
199
|
+
"""Create the __DOMAIN_TITLE__ agent with a default checkpointer for multi-turn state."""
|
|
200
|
+
return __DOMAIN_PASCAL__Agent(
|
|
201
|
+
client=client,
|
|
202
|
+
tools=create___DOMAIN___tools(client),
|
|
203
|
+
system_prompt=SYSTEM_PROMPT,
|
|
204
|
+
base_url=base_url or os.environ.get("LLM_BASE_URL") or DEFAULT_LLM_BASE_URL,
|
|
205
|
+
model=model or os.environ.get("LLM_MODEL") or DEFAULT_LLM_MODEL,
|
|
206
|
+
api_key=api_key or os.environ.get("LLM_API_KEY") or "not-needed",
|
|
207
|
+
checkpointer=checkpointer if checkpointer is not None else ConversationStateStore(),
|
|
208
|
+
transport=transport,
|
|
209
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Checkpointer-backed deepagents factory for the __DOMAIN_TITLE__ agent."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from deepagents import create_deep_agent
|
|
9
|
+
from langchain_core.tools import tool
|
|
10
|
+
from langchain_openai import ChatOpenAI
|
|
11
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
12
|
+
|
|
13
|
+
from .client import __DOMAIN_PASCAL__Client
|
|
14
|
+
|
|
15
|
+
DEFAULT_LLM_BASE_URL = "http://localhost:8080/v1"
|
|
16
|
+
DEFAULT_LLM_MODEL = "local-model"
|
|
17
|
+
|
|
18
|
+
# Keep SYSTEM_PROMPT compact (<= 120 words) and refactor rather than append patches.
|
|
19
|
+
SYSTEM_PROMPT = (
|
|
20
|
+
"You are a helpful __DOMAIN_TITLE__ assistant. Follow AGENTS.md strictly. "
|
|
21
|
+
"Ground every factual statement in domain tool outputs and never fabricate data. "
|
|
22
|
+
"If a request is vague or missing required identifiers, ask one clear clarifying question without calling tools. "
|
|
23
|
+
"If a tool returns an error, reply briefly and honestly without guessing missing values. "
|
|
24
|
+
"Politely decline requests outside the __DOMAIN__ domain."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def create___DOMAIN___tools(client: __DOMAIN_PASCAL__Client) -> list[Any]:
|
|
29
|
+
"""Bind domain tools to an injected __DOMAIN_PASCAL__Client implementation."""
|
|
30
|
+
__PYTHON_DEEPAGENTS_TOOLS__
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def create___DOMAIN___agent(
|
|
34
|
+
client: __DOMAIN_PASCAL__Client,
|
|
35
|
+
*,
|
|
36
|
+
base_url: str | None = None,
|
|
37
|
+
model: str | None = None,
|
|
38
|
+
api_key: str | None = None,
|
|
39
|
+
checkpointer: Any | None = None,
|
|
40
|
+
) -> Any:
|
|
41
|
+
"""Create the __DOMAIN_TITLE__ agent with a default checkpointer for multi-turn state."""
|
|
42
|
+
resolved_base_url = base_url or os.environ.get("LLM_BASE_URL") or DEFAULT_LLM_BASE_URL
|
|
43
|
+
resolved_model = model or os.environ.get("LLM_MODEL") or DEFAULT_LLM_MODEL
|
|
44
|
+
resolved_api_key = api_key or os.environ.get("LLM_API_KEY") or "not-needed"
|
|
45
|
+
resolved_checkpointer = checkpointer if checkpointer is not None else MemorySaver()
|
|
46
|
+
|
|
47
|
+
llm = ChatOpenAI(
|
|
48
|
+
base_url=resolved_base_url,
|
|
49
|
+
model=resolved_model,
|
|
50
|
+
api_key=lambda: resolved_api_key,
|
|
51
|
+
temperature=0,
|
|
52
|
+
use_responses_api=False,
|
|
53
|
+
)
|
|
54
|
+
return create_deep_agent(
|
|
55
|
+
model=llm,
|
|
56
|
+
memory=["./AGENTS.md"],
|
|
57
|
+
skills=["./skills/"],
|
|
58
|
+
tools=create___DOMAIN___tools(client),
|
|
59
|
+
checkpointer=resolved_checkpointer,
|
|
60
|
+
system_prompt=SYSTEM_PROMPT,
|
|
61
|
+
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Runnable CLI entrypoint for __PROJECT_NAME__."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from .agent import create___DOMAIN___agent
|
|
10
|
+
from .client import Default__DOMAIN_PASCAL__Client
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _extract_reply(result: Any) -> str:
|
|
14
|
+
if isinstance(result, dict):
|
|
15
|
+
if "final_response" in result:
|
|
16
|
+
return str(result["final_response"])
|
|
17
|
+
messages = result.get("messages") or []
|
|
18
|
+
for msg in reversed(messages):
|
|
19
|
+
role = getattr(msg, "type", None) or (msg.get("role") if isinstance(msg, dict) else None)
|
|
20
|
+
if role in {"ai", "assistant"}:
|
|
21
|
+
content = getattr(msg, "content", None) if not isinstance(msg, dict) else msg.get("content")
|
|
22
|
+
if isinstance(content, str) and content.strip():
|
|
23
|
+
return content.strip()
|
|
24
|
+
return str(result)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _send_turn(agent: Any, prompt: str, thread_id: str) -> str:
|
|
28
|
+
if hasattr(agent, "run_turn"):
|
|
29
|
+
return _extract_reply(agent.run_turn(prompt, thread_id=thread_id))
|
|
30
|
+
result = agent.invoke(
|
|
31
|
+
{"messages": [{"role": "user", "content": prompt}]},
|
|
32
|
+
config={"configurable": {"thread_id": thread_id}},
|
|
33
|
+
)
|
|
34
|
+
return _extract_reply(result)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def main(argv: list[str] | None = None) -> int:
|
|
38
|
+
parser = argparse.ArgumentParser(description="Run the __DOMAIN_TITLE__ agent interactively or with --prompt.")
|
|
39
|
+
parser.add_argument("--prompt", default=None, help="Run a single user prompt and exit.")
|
|
40
|
+
parser.add_argument("--thread-id", default="interactive", help="Conversation thread ID for checkpointer state.")
|
|
41
|
+
parser.add_argument("--base-url", default=None, help="Override LLM_BASE_URL.")
|
|
42
|
+
parser.add_argument("--model", default=None, help="Override LLM_MODEL.")
|
|
43
|
+
parser.add_argument("--api-key", default=None, help="Override LLM_API_KEY.")
|
|
44
|
+
args = parser.parse_args(argv)
|
|
45
|
+
|
|
46
|
+
agent = create___DOMAIN___agent(
|
|
47
|
+
client=Default__DOMAIN_PASCAL__Client(),
|
|
48
|
+
base_url=args.base_url,
|
|
49
|
+
model=args.model,
|
|
50
|
+
api_key=args.api_key,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if args.prompt:
|
|
54
|
+
print(_send_turn(agent, args.prompt, args.thread_id))
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
print("__DOMAIN_TITLE__ agent ready. Type 'exit' or Ctrl-D to quit.")
|
|
58
|
+
while True:
|
|
59
|
+
try:
|
|
60
|
+
user_input = input("you> ").strip()
|
|
61
|
+
except (EOFError, KeyboardInterrupt):
|
|
62
|
+
print()
|
|
63
|
+
break
|
|
64
|
+
if not user_input or user_input.lower() in {"exit", "quit"}:
|
|
65
|
+
break
|
|
66
|
+
print(f"agent> {_send_turn(agent, user_input, args.thread_id)}")
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""External service client Protocol and runnable default stub for __DOMAIN_TITLE__."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Protocol, runtime_checkable
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class DomainRecord:
|
|
11
|
+
"""Immutable value object returned by __DOMAIN_TITLE__ client operations."""
|
|
12
|
+
|
|
13
|
+
query: str
|
|
14
|
+
status: str
|
|
15
|
+
detail: str = ""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@runtime_checkable
|
|
19
|
+
class __DOMAIN_PASCAL__Client(Protocol):
|
|
20
|
+
"""Protocol hiding external APIs so evaluations can inject deterministic fakes."""
|
|
21
|
+
|
|
22
|
+
__PYTHON_PROTOCOL_METHODS__
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Default__DOMAIN_PASCAL__Client:
|
|
26
|
+
"""Runnable default client stub.
|
|
27
|
+
|
|
28
|
+
TODO(domain): Replace stub responses with real external API / database calls.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
__PYTHON_STUB_METHODS__
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: evoloop-scenarios
|
|
3
|
+
description: Author, refine, and validate YAML evaluation scenarios under `evals/datasets/`. Enforces factual grounding tokens, anti-hallucination forbidden substrings, per-turn assertions, and deterministic rubric criteria, then runs the schema validator.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Evoloop Scenarios
|
|
7
|
+
|
|
8
|
+
Translate project requirements, edge cases, and rules from `.evoloop/constitution.md`, `AGENTS.md`, and `skills/**/SKILL.md` into standardized, validated YAML scenarios under `evals/datasets/`.
|
|
9
|
+
|
|
10
|
+
## Authoring Rules (Grounded in Runs 1–10 Lessons)
|
|
11
|
+
|
|
12
|
+
Read `templates/scenario_schema.md` for the full YAML schema. Follow these rules strictly:
|
|
13
|
+
|
|
14
|
+
1. **Cover all core behavioral categories:**
|
|
15
|
+
- `happy_path` (default behavior & tool pairing)
|
|
16
|
+
- `unit_normalization` / `parameter_normalization`
|
|
17
|
+
- `multi_entity` (batching multiple lookups without looping or hallucinating)
|
|
18
|
+
- `input_validation` (vague/missing inputs → `expected_tool_calls: []`, `trajectory_match_mode: strict`, `max_tool_calls: 0`, `forbidden_tools`)
|
|
19
|
+
- `multi_turn` (clarification & context-retention follow-ups using `turn_assertions`)
|
|
20
|
+
- `error_recovery` (not-found + simulated outage via `fake_client.fail_mode`)
|
|
21
|
+
- `edge_case` (unsupported parameters / boundary values)
|
|
22
|
+
- `scope_adherence` (out-of-scope requests)
|
|
23
|
+
2. **No brittle synonym lists in `grounded_any_of`:**
|
|
24
|
+
- Put only **objective factual tokens** (numbers, units, entity names, status keywords) in `grounded_any_of`.
|
|
25
|
+
- Never put 5+ open-ended conversational synonyms (e.g., `["sorry", "unable", "cannot", "not found", "couldn't", "apologize"]`) into `grounded_any_of`—delegate phrasing quality to `rubric_criteria` and the LLM judge.
|
|
26
|
+
3. **Use `forbidden_substrings` for anti-hallucination:**
|
|
27
|
+
- On error recovery or unsupported-parameter cases, explicitly forbid leaked units, fabricated values, or unrequested conversion formulas (e.g., `"$0.00"`, `"EUR"`, `"USD"`).
|
|
28
|
+
4. **Use `turn_assertions` for every multi-turn scenario:**
|
|
29
|
+
- Constrain `turn_index: 0` and `turn_index: 1` with `forbidden_tools` and `required_tools` so premature tool calls or skipped follow-up calls are caught deterministically.
|
|
30
|
+
5. **Write deterministic `rubric_criteria`:**
|
|
31
|
+
- Describe one clear expected behavior per scenario. Avoid contradictory or vague "either/or" rubrics.
|
|
32
|
+
|
|
33
|
+
## Writing Style Requirement
|
|
34
|
+
|
|
35
|
+
Before writing or editing scenarios or YAML comments, read [`../evoloop-constitution/references/writing-guide.md`](../evoloop-constitution/references/writing-guide.md) (`.agents/skills/evoloop-constitution/references/writing-guide.md`). Apply its Simplified Technical English rules to every scenario `description`, `rubric_criteria`, YAML comment, and any accompanying scenario documentation.
|
|
36
|
+
|
|
37
|
+
## Workflow
|
|
38
|
+
|
|
39
|
+
1. Read `.evoloop/constitution.md`, `.evoloop/config.yaml`, `AGENTS.md`, `evals/fakes.py`, and `evals/harness.py` (to inspect `DOMAIN_TOOLS` and supported `fake_client` modes).
|
|
40
|
+
2. Draft or update the YAML dataset at the path configured in `.evoloop/config.yaml` (`paths.dataset`).
|
|
41
|
+
- **Important:** If `.evoloop/.evolve-lock` is active, DO NOT modify existing scenarios without explicit user approval!
|
|
42
|
+
3. Run the deterministic schema & anti-pattern validator:
|
|
43
|
+
```bash
|
|
44
|
+
uv run .agents/skills/evoloop-scenarios/scripts/validate_scenarios.py \
|
|
45
|
+
<dataset_path> \
|
|
46
|
+
--config .evoloop/config.yaml \
|
|
47
|
+
--harness evals/harness.py
|
|
48
|
+
```
|
|
49
|
+
4. Fix all reported errors (and address warnings about brittle synonym lists or missing `turn_assertions`), then re-run the validator and `uv run pytest` (offline tests) to verify `test_dataset_loads_all_cases` passes.
|