Agent context for maintaining state across tool calls. More...
#include <agent_context.h>

Public Member Functions | |
| AgentContext ()=default | |
| void | SetRom (Rom *rom) |
| Set the current ROM context. | |
| Rom * | GetRom () const |
| Get the current ROM context. | |
| bool | HasRom () const |
| Check if a ROM is loaded. | |
| const std::string & | GetRomPath () const |
| Get the current ROM path. | |
| void | SetRomPath (const std::string &path) |
| Set the current ROM path. | |
| void | AddPendingEdit (const RomEdit &edit) |
| Record a pending ROM edit. | |
| const std::vector< RomEdit > & | GetPendingEdits () const |
| Get all pending edits. | |
| bool | HasPendingEdits () const |
| Check if there are pending edits. | |
| void | ClearPendingEdits () |
| Clear all pending edits. | |
| absl::Status | CommitPendingEdits () |
| Commit all pending edits to the ROM. | |
| void | RollbackPendingEdits () |
| Rollback all pending edits. | |
| void | RecordToolCall (const ToolCallRecord &record) |
| Record a tool call. | |
| const std::vector< ToolCallRecord > & | GetCallHistory () const |
| Get tool call history. | |
| std::vector< ToolCallRecord > | GetRecentCalls (size_t n) const |
| Get the last N tool calls. | |
| void | ClearCallHistory () |
| Clear tool call history. | |
| void | SetVariable (const std::string &key, const std::string &value) |
| Set a session variable. | |
| std::optional< std::string > | GetVariable (const std::string &key) const |
| Get a session variable. | |
| bool | HasVariable (const std::string &key) const |
| Check if a session variable exists. | |
| void | ClearVariables () |
| Clear all session variables. | |
| const std::map< std::string, std::string > & | GetAllVariables () const |
| Get all session variables. | |
| DungeonCache & | GetDungeonCache () |
| Get dungeon cache. | |
| const DungeonCache & | GetDungeonCache () const |
| OverworldCache & | GetOverworldCache () |
| Get overworld cache. | |
| const OverworldCache & | GetOverworldCache () const |
| void | InvalidateCaches () |
| Invalidate all caches. | |
| const std::string & | GetSessionId () const |
| Get session ID. | |
| void | SetSessionId (const std::string &id) |
| Set session ID. | |
| std::chrono::system_clock::time_point | GetSessionStartTime () const |
| Get session start time. | |
| void | ResetSession () |
| Reset the session (clear all state except ROM) | |
| std::string | GenerateSummary () const |
| Generate a summary of the current context. | |
Private Attributes | |
| Rom * | current_rom_ = nullptr |
| std::string | rom_path_ |
| std::vector< RomEdit > | pending_edits_ |
| std::vector< ToolCallRecord > | call_history_ |
| std::map< std::string, std::string > | session_vars_ |
| std::string | session_id_ |
| std::chrono::system_clock::time_point | session_start_time_ |
| DungeonCache | dungeon_cache_ |
| OverworldCache | overworld_cache_ |
| size_t | max_history_size_ = 100 |
Agent context for maintaining state across tool calls.
Provides:
Definition at line 100 of file agent_context.h.
|
default |
|
inline |
Set the current ROM context.
Definition at line 111 of file agent_context.h.
References current_rom_, and InvalidateCaches().

|
inline |
Get the current ROM context.
Definition at line 119 of file agent_context.h.
References current_rom_.
|
inline |
|
inline |
|
inline |
|
inline |
Record a pending ROM edit.
Definition at line 143 of file agent_context.h.
References pending_edits_.
|
inline |
|
inline |
Check if there are pending edits.
Definition at line 153 of file agent_context.h.
References pending_edits_.
|
inline |
|
inline |
Commit all pending edits to the ROM.
Definition at line 163 of file agent_context.h.
References current_rom_, InvalidateCaches(), pending_edits_, and yaze::Rom::WriteByte().

|
inline |
Rollback all pending edits.
Definition at line 182 of file agent_context.h.
References pending_edits_.
|
inline |
Record a tool call.
Definition at line 194 of file agent_context.h.
References call_history_, and max_history_size_.
|
inline |
|
inline |
Get the last N tool calls.
Definition at line 213 of file agent_context.h.
References call_history_.
|
inline |
|
inline |
|
inline |
|
inline |
Check if a session variable exists.
Definition at line 251 of file agent_context.h.
References session_vars_.
|
inline |
Clear all session variables.
Definition at line 258 of file agent_context.h.
References session_vars_.
|
inline |
Get all session variables.
Definition at line 263 of file agent_context.h.
References session_vars_.
|
inline |
|
inline |
Definition at line 275 of file agent_context.h.
References dungeon_cache_.
|
inline |
|
inline |
Definition at line 281 of file agent_context.h.
References overworld_cache_.
|
inline |
Invalidate all caches.
Definition at line 286 of file agent_context.h.
References dungeon_cache_, yaze::cli::agent::DungeonCache::Invalidate(), yaze::cli::agent::OverworldCache::Invalidate(), and overworld_cache_.
Referenced by CommitPendingEdits(), ResetSession(), and SetRom().

|
inline |
|
inline |
|
inline |
Get session start time.
Definition at line 308 of file agent_context.h.
References session_start_time_.
|
inline |
Reset the session (clear all state except ROM)
Definition at line 315 of file agent_context.h.
References call_history_, InvalidateCaches(), pending_edits_, session_start_time_, and session_vars_.

|
inline |
Generate a summary of the current context.
Definition at line 326 of file agent_context.h.
References call_history_, current_rom_, dungeon_cache_, yaze::cli::agent::DungeonCache::IsValid(), yaze::cli::agent::OverworldCache::IsValid(), overworld_cache_, pending_edits_, rom_path_, and session_vars_.

|
private |
Definition at line 345 of file agent_context.h.
Referenced by CommitPendingEdits(), GenerateSummary(), GetRom(), HasRom(), and SetRom().
|
private |
Definition at line 346 of file agent_context.h.
Referenced by GenerateSummary(), GetRomPath(), and SetRomPath().
|
private |
Definition at line 347 of file agent_context.h.
Referenced by AddPendingEdit(), ClearPendingEdits(), CommitPendingEdits(), GenerateSummary(), GetPendingEdits(), HasPendingEdits(), ResetSession(), and RollbackPendingEdits().
|
private |
Definition at line 350 of file agent_context.h.
Referenced by ClearCallHistory(), GenerateSummary(), GetCallHistory(), GetRecentCalls(), RecordToolCall(), and ResetSession().
|
private |
Definition at line 351 of file agent_context.h.
Referenced by ClearVariables(), GenerateSummary(), GetAllVariables(), GetVariable(), HasVariable(), ResetSession(), and SetVariable().
|
private |
Definition at line 352 of file agent_context.h.
Referenced by GetSessionId(), and SetSessionId().
|
private |
Definition at line 353 of file agent_context.h.
Referenced by GetSessionStartTime(), and ResetSession().
|
private |
Definition at line 357 of file agent_context.h.
Referenced by GenerateSummary(), GetDungeonCache(), GetDungeonCache(), and InvalidateCaches().
|
private |
Definition at line 358 of file agent_context.h.
Referenced by GenerateSummary(), GetOverworldCache(), GetOverworldCache(), and InvalidateCaches().
|
private |
Definition at line 361 of file agent_context.h.
Referenced by RecordToolCall().