mirror of
https://github.com/furyhawk/agent_alpha.git
synced 2026-07-21 02:25:34 +00:00
feat(agent): integrate LocalBackend for persistent agent memory and update MemoryCapability configuration
This commit is contained in:
+14
-3
@@ -10,7 +10,7 @@ from pydantic_ai.providers.openai import OpenAIProvider
|
||||
from pydantic_ai_harness import CodeMode
|
||||
|
||||
# Community packages, alphabetical:
|
||||
from pydantic_ai_backends import ConsoleCapability
|
||||
from pydantic_ai_backends import ConsoleCapability, LocalBackend
|
||||
from pydantic_ai_shields import CostTracking, InputGuard, SecretRedaction, ToolGuard
|
||||
from pydantic_ai_skills import SkillsCapability
|
||||
from pydantic_ai_summarization import ContextManagerCapability
|
||||
@@ -71,7 +71,7 @@ class AgentService:
|
||||
"""Send a prompt to the agent and return the text output."""
|
||||
self.initialize()
|
||||
assert self._agent is not None
|
||||
deps = DeepAgentDeps()
|
||||
deps = DeepAgentDeps(backend=_backend)
|
||||
result = await self._agent.run(prompt, deps=deps)
|
||||
return result.output
|
||||
|
||||
@@ -87,7 +87,7 @@ class AgentService:
|
||||
MCP("https://hn.caseyjhand.com/mcp", native=True),
|
||||
WebSearch(local="duckduckgo"),
|
||||
ConsoleCapability(),
|
||||
MemoryCapability(agent_name="harness-example"),
|
||||
MemoryCapability(agent_name="harness-agent", memory_dir=_MEMORY_DIR),
|
||||
SkillsCapability(directories=["./skills"]),
|
||||
SubAgentCapability(
|
||||
subagents=[
|
||||
@@ -108,6 +108,17 @@ class AgentService:
|
||||
]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Persistent backend — uses local filesystem so agent memory survives restarts.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
import os as _os
|
||||
|
||||
_AGENT_ROOT = _os.path.dirname(_os.path.dirname(_os.path.abspath(__file__)))
|
||||
_MEMORY_DIR = _os.path.join(_AGENT_ROOT, ".agent_memory")
|
||||
|
||||
_backend = LocalBackend(root_dir=_AGENT_ROOT)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Singleton — lazy-initialised on the first call to ``ask()``.
|
||||
# Keeps the existing module-level ``ask`` facade so downstream imports in
|
||||
|
||||
Reference in New Issue
Block a user