Skip to content

Day 4: BaseAgent contract redesign (closes KI-3, KI-4, KI-6)#4

Merged
evkir merged 4 commits into
mainfrom
refactor/base-agent-contract
May 22, 2026
Merged

Day 4: BaseAgent contract redesign (closes KI-3, KI-4, KI-6)#4
evkir merged 4 commits into
mainfrom
refactor/base-agent-contract

Conversation

@evkir
Copy link
Copy Markdown
Owner

@evkir evkir commented May 22, 2026

No description provided.

evkir added 4 commits May 22, 2026 09:04
BaseAgent.__init__ now takes (config, session, llm=None, audit=None)
and exposes everything agents actually reference:
  self.config, self.session, self.kb, self.llm, self.audit, self.memory

New on the base class:
- self.kb       — KnowledgeBase, taken from session or created fresh
- self.memory   — AgentMemory for multi-turn LLM context (ExploitAgent)
- _check_iteration_limit() — raises AgentIterationLimitError past
  config.max_agent_iterations; agents call it before major steps (KI-4)
- _log(msg, data) — alias for log(); several agents call _log (KI-4)

Tool dataclass: accepts both 'params' and 'parameters' kwargs, kept in
sync via __post_init__. Every agent registers tools with parameters=...
so this closes KI-6 without touching a single agent file.

New helpers:
- AgentMemory — add()/to_messages()/system/clear()
- AgentIterationLimitError — raised on runaway loops

Agents themselves are migrated to this contract in day 6; this commit
only widens/fixes the base class.

Refs: STANDOFF.md day 4/30
Three changes needed before agents migrate to the new BaseAgent (day 6):
- set() agent param now defaults to 'unknown' — agents like ExploitAgent
  call self.kb.set('exploit', result) without naming themselves
- get() gained a default param: kb.get(key, default)
- mutable default tags=[] bug fixed (was shared across all entries)
- datetime.utcnow() replaced with timezone-aware datetime.now(timezone.utc)

Added dict-like access (__contains__, __getitem__, __setitem__, __len__)
since some agents treat the KB like a dict (kb['recon.nmap']).

Refs: STANDOFF.md day 4/30
@evkir evkir merged commit 2903e92 into main May 22, 2026
4 checks passed
@evkir evkir deleted the refactor/base-agent-contract branch May 22, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant