ContextAgent
- class hana_ai.agents.context_agent.ContextAgent(llm: Any, tools: Sequence[Tool] | None = None, *, storage_dir: str = '.context_agent', session_id: str = 'global_session', config: AgentConfig | None = None, progress_bar: bool = False, progress_callback: Callable[[str], None] | None = None)
Context-engineered agent backed by Markdown memory.
The agent persists long-lived and session-scoped state as Markdown files under
storage_dirand supports command-style memory maintenance throughchat().Memory cleanup commands: - Aggregate commands:
!clear_notesclearsNOTES.md,TODO.md,DECISIONS.md, andCONTEXT.md.!clear_sessionclears the current sessionchat.mdandsession_summary.md.!reset_memoryclears both the global note files and the current session files.
File-level commands: -
!clear_notes_fileclears onlyNOTES.md. -!clear_todoclears onlyTODO.md. -!clear_decisionsclears onlyDECISIONS.md. -!clear_contextclears onlyCONTEXT.md. -!clear_chatclears only the current sessionchat.md. -!clear_summaryclears only the current sessionsession_summary.md.
Skill control commands: - Aggregate commands:
!list_skillslists all available skills and their short descriptions.!active_skillsreports the skills currently active for the request-routing state.!skills_onre-enables skill injection for subsequent requests.!skills_offdisables skill injection for subsequent requests.
Skill-level commands: -
!enable_skill <skill_name>force-enables a named skill when it exists in the catalog. -!disable_skill <skill_name>suppresses a named skill from future activation.
All cleanup commands preserve the storage directory layout and recreate files with their default Markdown headings so retrieval and future writes can continue normally. Skill commands update only in-memory routing state for the current agent instance; they do not modify the persisted Markdown memory files.
Methods
chat(user_input)Run one conversational turn and persist it to Markdown memory.
Clear the current session chat history markdown file.
Clear the persisted CONTEXT markdown file.
Clear the persisted DECISIONS markdown file.
Clear all persisted non-session memory note files.
Clear the persisted NOTES markdown file.
Clear the current session chat history and session summary files.
Clear the current session summary markdown file.
Clear the persisted TODO markdown file.
Clear both persisted note files and the current session memory files.
- clear_notes_file() None
Clear the persisted NOTES markdown file.
- clear_todo_file() None
Clear the persisted TODO markdown file.
- clear_decisions_file() None
Clear the persisted DECISIONS markdown file.
- clear_context_file() None
Clear the persisted CONTEXT markdown file.
- clear_chat_history() None
Clear the current session chat history markdown file.
- clear_session_summary() None
Clear the current session summary markdown file.
- clear_memory_notes() None
Clear all persisted non-session memory note files.
- clear_session_memory() None
Clear the current session chat history and session summary files.
- reset_memory() None
Clear both persisted note files and the current session memory files.
- chat(user_input: str) str
Run one conversational turn and persist it to Markdown memory.