Skip to content

Commit 8d4a9a5

Browse files
authored
highlights docs page (#182)
* highlights * Update ghpages.yml
1 parent 1c4ee13 commit 8d4a9a5

4 files changed

Lines changed: 674 additions & 0 deletions

File tree

47.1 KB
Loading

docs/en/highlights.md

Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
# Highlights
2+
3+
This page answers one simple question: **What's cool about this framework?**
4+
Short cases and intuitive examples; for more complete and detailed docs go to:
5+
6+
- [Main Concepts](framework/main-concepts.md)
7+
- [Configuration Guide](framework/configuration.md)
8+
- [Getting Started](getting-started/index.md)
9+
10+
---
11+
12+
## 1. What is this?
13+
14+
SGR Agent Core is a **platform framework for building and running AI agents**, implementing our team's ideas on how to construct, study, and apply agent technologies from research to production pipelines.
15+
16+
The central idea is Schema-Guided Reasoning — an approach that produces deterministic, interpretable results across a wide range of LLMs, from large 70B+ models down to 7B (with caveats) or MoE 20B. We value stable, reusable per-step outputs that can be displayed, reused, and integrated into classic code systems.
17+
18+
**We don't aim to build a system that does everything at once.** </br>
19+
The framework gives you enough to describe and run an agent quickly, plus a set of abstractions (`BaseAgent`, `BaseTool`, `BaseStreamingGenerator`, etc.) for deeper customization.
20+
21+
The `/examples` folder showcases more advanced patterns:
22+
23+
- **[Progressive Tool Discovery](https://github.com/vamplabai/sgr-agent-core/tree/main/examples/progressive_discovery)** — working with 50+ tools without bloating the LLM context
24+
- **[SGR File Agent](https://github.com/vamplabai/sgr-agent-core/tree/main/examples/sgr_file_agent)** — file search by pattern/date/size, reading, grep
25+
- **[Research with Images](https://github.com/vamplabai/sgr-agent-core/tree/main/examples/research_with_images)** — multimodal requests to an agent
26+
27+
More concretely:
28+
29+
**Mini-example: create and run an agent directly**
30+
31+
```python
32+
import asyncio
33+
34+
from openai import AsyncOpenAI
35+
36+
from sgr_agent_core import AgentConfig
37+
from sgr_agent_core.agents.sgr_agent import SGRAgent
38+
from sgr_agent_core.tools.final_answer_tool import FinalAnswerTool
39+
40+
41+
async def main() -> None:
42+
client = AsyncOpenAI(api_key="YOUR_OPENAI_API_KEY")
43+
44+
agent = SGRAgent(
45+
task_messages=[
46+
{"role": "user", "content": "Give a brief overview of RAG systems"},
47+
],
48+
openai_client=client,
49+
agent_config=AgentConfig(),
50+
toolkit=[FinalAnswerTool],
51+
)
52+
53+
result = await agent.execute()
54+
print(result)
55+
56+
57+
if __name__ == "__main__":
58+
asyncio.run(main())
59+
```
60+
61+
The idea: you describe an agent (in code or a config file) and run it for a specific task.
62+
63+
---
64+
65+
## 2. How to use it
66+
67+
### You're a developer building custom agents
68+
69+
**-->RTFM**
70+
71+
- install `sgr-agent-core`;
72+
- read the [configuration](framework/configuration.md) and [main concepts](framework/main-concepts.md) sections;
73+
- describe agents via `config.yaml` and `agents.yaml` (or any other convenient form);
74+
- extend base entities in code to fit your agent's logic and tools;
75+
- call `execute()`.
76+
77+
**Mini-example: create an agent from configs and run it**
78+
79+
```python
80+
from sgr_agent_core import GlobalConfig, AgentFactory
81+
82+
config = GlobalConfig.from_yaml("config.yaml")
83+
config.definitions_from_yaml("agents.yaml")
84+
85+
researcher_def = config.agents["researcher"]
86+
agent = await AgentFactory.create(
87+
researcher_def,
88+
task_messages=[{"role": "user", "content": "Find recent articles on multi-agent systems"}],
89+
)
90+
await agent.execute()
91+
```
92+
93+
### You want to use a ready-made solution
94+
95+
Think of it like docker compose — **one YAML that describes what to do**:
96+
97+
1. Take a ready config from `/examples`, colleagues, or write your own `config.yaml`.
98+
2. Put it in your project folder.
99+
3. Start the server:
100+
101+
```bash
102+
sgr -c config.yaml
103+
```
104+
105+
4. An API spins up — by default at `http://localhost:8010`, Swagger at `http://localhost:8010/docs`.
106+
5. Send requests using the OpenAI chat/completions protocol.
107+
108+
More details — [API Server Quick Start](sgr-api/SGR-Quick-Start.md).
109+
110+
---
111+
112+
## 3. How to get output from an agent?
113+
114+
There are two options:
115+
116+
### Run, wait, get result
117+
118+
- create an agent;
119+
- call `execute()`;
120+
- get the final result.
121+
122+
**Mini-example: get the final result from agent context**
123+
124+
```python
125+
result = await agent.execute()
126+
127+
print(result)
128+
129+
# or directly from context
130+
print(agent._context.execution_result)
131+
```
132+
133+
This is convenient when you only care about the final answer, not the process.
134+
135+
### Run and stream — watch it happen
136+
137+
- enable streaming mode;
138+
- connect to the stream and process events as they arrive;
139+
- build interfaces with a "live" view of the agent's work.
140+
141+
**Mini-example: API request with streaming enabled**
142+
143+
```bash
144+
curl -X POST "http://localhost:8010/v1/chat/completions" \
145+
-H "Content-Type: application/json" \
146+
-d '{
147+
"model": "sgr_agent",
148+
"messages": [
149+
{"role": "user", "content": "Research the RAG systems market and give a brief conclusion"}
150+
],
151+
"stream": true
152+
}'
153+
```
154+
155+
The response comes as Server-Sent Events — read the stream line by line and update your UI or logs in real time.
156+
157+
```
158+
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":""},"index":0}]}
159+
160+
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"tool_calls":[{"index":0,"id":"1-reasoning","type":"function","function":{"name":"reasoning_tool","arguments":""}}]},"index":0}]}
161+
162+
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"reasoning_steps\":[\"Need to find current data on the RAG market\"],\"plan_status\":\"In progress\"}"}}]},"index":0}]}
163+
164+
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"tool_calls":[{"index":0,"id":"1-action","type":"function","function":{"name":"web_search_tool","arguments":"{\"query\":\"RAG systems market 2025\"}"}}]},"index":0}]}
165+
166+
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"The RAG systems market in 2025..."}},"index":0}]}
167+
168+
data: [DONE]
169+
```
170+
171+
---
172+
173+
## 4. How to get a nice UI for your agent?
174+
175+
You can connect [Open WebUI](https://github.com/open-webui/open-webui): it understands OpenAI-compatible APIs out of the box. Point it at your server address — and get a full chat interface with history, agent switching, and streaming without writing a single line of frontend code.
176+
177+
```bash
178+
docker run -d \
179+
-p 3000:8080 \
180+
-e OPENAI_API_BASE_URL=http://host.docker.internal:8010/v1 \
181+
-e OPENAI_API_KEY=dummy \
182+
ghcr.io/open-webui/open-webui:main
183+
```
184+
185+
After startup open `http://localhost:3000` — agents from your config will appear in the models list.
186+
187+
![Open WebUI with SGR agent](../assets/images/openwebui_example.png)
188+
189+
> **Important:** when connecting to Open WebUI you need to switch the streaming adapter. In `config.yaml` set:
190+
> ```yaml
191+
> execution:
192+
> streaming_generator: "open_webui" # instead of "openai" (default)
193+
> ```
194+
195+
---
196+
197+
## 5. How to run many agents?
198+
199+
The framework uses a **two-level config system** based on `GlobalConfig`, `AgentDefinition`, and `ToolDefinition`. In practice:
200+
201+
- one base `config.yaml` with shared settings (model, limits, log/report directories);
202+
- one or more agent definition files (`agents.yaml`, `more_agents.yaml`, etc.).
203+
- note: both global config and agent configs can be combined into a single file if preferred.
204+
205+
Simplest mental model:
206+
207+
- keep it simple — one config, one universal agent;
208+
- go deeper — define each agent with separate roles and tools, inheriting shared parameters from the base config.
209+
210+
> We find YAML-based configuration a great way to avoid boilerplate code, deep inheritance chains, excessive imports, and other organizational headaches. All core modules are designed so you can easily point to custom models and classes, add your own parameters by just appending them to the existing ones.
211+
212+
**Mini-example: two different agents in `agents.yaml`**
213+
214+
```yaml
215+
agents:
216+
researcher:
217+
base_class: "IronAgent"
218+
llm:
219+
model: "gpt-4o"
220+
tools:
221+
- "web_search_tool"
222+
- "extract_page_content_tool"
223+
- "create_report_tool"
224+
- "final_answer_tool"
225+
226+
planner:
227+
base_class: "SGRToolCallingAgent"
228+
llm:
229+
model: "gpt-4o-mini"
230+
tools:
231+
- "generate_plan_tool"
232+
- "adapt_plan_tool"
233+
- "final_answer_tool"
234+
```
235+
236+
Full configuration schema and examples in [Configuration Guide](framework/configuration.md).
237+
238+
---
239+
240+
## 6. How to understand when something goes wrong?
241+
242+
The framework is built around **mandatory validation of every entity the agent creates**:
243+
244+
- at each step, objects are created against predefined schemas;
245+
- the result is validated before moving on;
246+
- on schema mismatch, execution fails with a clear error rather than a silent undefined response.
247+
248+
This means:
249+
250+
- you either get valid data or a clear error;
251+
- it's visible at which step and which part of the pipeline something went wrong.
252+
253+
**Mini-example: catch an error and inspect agent state**
254+
255+
```python
256+
from sgr_agent_core import AgentStatesEnum
257+
258+
try:
259+
await agent.execute()
260+
except Exception as exc:
261+
print(f"Agent failed: {exc}")
262+
print("State:", agent._context.state)
263+
if agent._context.state in {AgentStatesEnum.ERROR, AgentStatesEnum.FAILED}:
264+
print("Execution result:", agent._context.execution_result)
265+
```
266+
267+
When something goes wrong, it shows up as a state and exception — not as a random hallucination in the text.
268+
**Catch exceptions, pipe them into telemetry systems, send more stable agents to deal with less stable ones.**
269+
270+
---
271+
272+
## 7. What if my model isn't smart enough for agentic tasks?
273+
274+
SGR methodology enables structured reasoning even when the model can't do it on its own. Our [benchmark](https://github.com/vamplabai/sgr-agent-core/tree/main/benchmark) showed `gpt-4.1-mini` with the framework hits **Accuracy = 0.861** on SimpleQA — competitive even against solutions built on much larger models.
275+
276+
If your model doesn't support tool calling or structured output at all — there's **`IronAgent`**: it works with raw model responses, extracts tool name and parameters itself, and retries on failure.
277+
278+
The exact answer for your specific model and task only comes from running your own benchmarks.
279+
280+
---
281+
282+
## 8. I have an amazing million-dollar idea but the framework doesn't support it
283+
284+
The framework is designed as a base for complex custom solutions.
285+
286+
Several extension options:
287+
288+
- subclass `BaseAgent`, `BaseTool`, `BaseStreamingGenerator` and add your own behavior;
289+
- describe new agents and tools via config, reusing existing implementations;
290+
- combine both: custom code logic + declarative YAML settings.
291+
292+
Registries and configuration make this transparent:
293+
294+
- new agents and tools are registered and become available by name;
295+
- configuration lets you replace or extend behavior without hardcoded dependencies.
296+
297+
**Mini-example: custom tool and agent using it**
298+
299+
```python
300+
from sgr_agent_core import BaseTool, AgentConfig, AgentDefinition, AgentFactory
301+
from sgr_agent_core import AgentContext
302+
from sgr_agent_core.agents.tool_calling_agent import ToolCallingAgent
303+
from sgr_agent_core.tools import GeneratePlanTool, FinalAnswerTool
304+
305+
306+
class SummarizeNotesTool(BaseTool):
307+
"""Summarize raw notes into a short summary."""
308+
309+
text: str
310+
311+
async def __call__(self, context: AgentContext, config: AgentConfig) -> str:
312+
# Integration with your system or model would go here
313+
return self.text[:200]
314+
315+
316+
custom_config = AgentConfig(
317+
tools=[GeneratePlanTool, SummarizeNotesTool, FinalAnswerTool],
318+
)
319+
320+
custom_def = AgentDefinition(
321+
name="notes_summarizer",
322+
base_class=ToolCallingAgent,
323+
**custom_config.model_dump(),
324+
)
325+
326+
agent = await AgentFactory.create(
327+
custom_def,
328+
task_messages=[
329+
{"role": "user", "content": "Summarize my notes into a short summary"},
330+
],
331+
)
332+
```
333+
334+
You can start with simple extensions like this and grow them into a full multi-agent system with rich configuration.
335+
*If the idea is genuinely great, write to us or the community — we'll point you in the right direction =)*

0 commit comments

Comments
 (0)