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_dir and supports command-style memory maintenance through chat().

Memory cleanup commands: - Aggregate commands:

  • !clear_notes clears NOTES.md, TODO.md, DECISIONS.md, and CONTEXT.md.

  • !clear_session clears the current session chat.md and session_summary.md.

  • !reset_memory clears both the global note files and the current session files.

  • File-level commands: - !clear_notes_file clears only NOTES.md. - !clear_todo clears only TODO.md. - !clear_decisions clears only DECISIONS.md. - !clear_context clears only CONTEXT.md. - !clear_chat clears only the current session chat.md. - !clear_summary clears only the current session session_summary.md.

Skill control commands: - Aggregate commands:

  • !list_skills lists all available skills and their short descriptions.

  • !active_skills reports the skills currently active for the request-routing state.

  • !skills_on re-enables skill injection for subsequent requests.

  • !skills_off disables 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_chat_history()

Clear the current session chat history markdown file.

clear_context_file()

Clear the persisted CONTEXT markdown file.

clear_decisions_file()

Clear the persisted DECISIONS markdown file.

clear_memory_notes()

Clear all persisted non-session memory note files.

clear_notes_file()

Clear the persisted NOTES markdown file.

clear_session_memory()

Clear the current session chat history and session summary files.

clear_session_summary()

Clear the current session summary markdown file.

clear_todo_file()

Clear the persisted TODO markdown file.

reset_memory()

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.