Day 4: BaseAgent contract redesign (closes KI-3, KI-4, KI-6)#4
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.