agentgit.core package

Submodules

agentgit.core.rollback_protocol module

Rollback protocol for tool operations in the LangGraph agent system.

class agentgit.core.rollback_protocol.ReverseInvocationResult(tool_name, reversed_successfully, error_message=None)[source]

Bases: object

Result of a reverse tool operation.

error_message: Optional[str] = None
reversed_successfully: bool
tool_name: str
class agentgit.core.rollback_protocol.ToolInvocationRecord(tool_name, args, result, success, error_message=None)[source]

Bases: object

Record of a tool invocation.

args: Dict[str, Any]
error_message: Optional[str] = None
result: Any
success: bool
tool_name: str
class agentgit.core.rollback_protocol.ToolRollbackRegistry[source]

Bases: object

Registry for managing reversible tool operations.

get_tool(name)[source]

Get a tool specification by name.

Parameters:

name (str) – Tool name

Return type:

Optional[ToolSpec]

Returns:

Tool specification or None if not found

get_track()[source]

Get the current tool invocation track.

Return type:

List[ToolInvocationRecord]

Returns:

List of tool invocation records

record_invocation(tool_name, args, result, success=True, error_message=None)[source]

Record a tool invocation.

Parameters:
  • tool_name (str) – Name of the tool

  • args (Dict[str, Any]) – Arguments passed to the tool

  • result (Any) – Result from the tool

  • success (bool) – Whether the invocation succeeded

  • error_message (Optional[str]) – Optional error message if failed

redo()[source]

Re-execute forward handlers for recorded tools.

Return type:

List[ToolInvocationRecord]

Returns:

List of new invocation records

register_tool(spec)[source]

Register a tool with optional reverse handler.

Parameters:

spec (ToolSpec) – Tool specification with forward and optional reverse functions

rollback()[source]

Rollback all recorded tool invocations.

Return type:

List[ReverseInvocationResult]

Returns:

List of reverse invocation results

truncate_track(position)[source]

Truncate the track to a specific position.

Parameters:

position (int) – Position to truncate to

class agentgit.core.rollback_protocol.ToolSpec(name, forward, reverse=None)[source]

Bases: object

Specification for a reversible tool.

forward: Callable[[Mapping[str, Any]], Any]
name: str
reverse: Optional[Callable[[Mapping[str, Any], Any], Any]] = None

Module contents

Core components and protocols for the rollback system.

class agentgit.core.ReverseInvocationResult(tool_name, reversed_successfully, error_message=None)[source]

Bases: object

Result of a reverse tool operation.

error_message: Optional[str] = None
reversed_successfully: bool
tool_name: str
class agentgit.core.ToolInvocationRecord(tool_name, args, result, success, error_message=None)[source]

Bases: object

Record of a tool invocation.

args: Dict[str, Any]
error_message: Optional[str] = None
result: Any
success: bool
tool_name: str
class agentgit.core.ToolRollbackRegistry[source]

Bases: object

Registry for managing reversible tool operations.

get_tool(name)[source]

Get a tool specification by name.

Parameters:

name (str) – Tool name

Return type:

Optional[ToolSpec]

Returns:

Tool specification or None if not found

get_track()[source]

Get the current tool invocation track.

Return type:

List[ToolInvocationRecord]

Returns:

List of tool invocation records

record_invocation(tool_name, args, result, success=True, error_message=None)[source]

Record a tool invocation.

Parameters:
  • tool_name (str) – Name of the tool

  • args (Dict[str, Any]) – Arguments passed to the tool

  • result (Any) – Result from the tool

  • success (bool) – Whether the invocation succeeded

  • error_message (Optional[str]) – Optional error message if failed

redo()[source]

Re-execute forward handlers for recorded tools.

Return type:

List[ToolInvocationRecord]

Returns:

List of new invocation records

register_tool(spec)[source]

Register a tool with optional reverse handler.

Parameters:

spec (ToolSpec) – Tool specification with forward and optional reverse functions

rollback()[source]

Rollback all recorded tool invocations.

Return type:

List[ReverseInvocationResult]

Returns:

List of reverse invocation results

truncate_track(position)[source]

Truncate the track to a specific position.

Parameters:

position (int) – Position to truncate to

class agentgit.core.ToolSpec(name, forward, reverse=None)[source]

Bases: object

Specification for a reversible tool.

forward: Callable[[Mapping[str, Any]], Any]
name: str
reverse: Optional[Callable[[Mapping[str, Any], Any], Any]] = None