dragon.ai.agent.ddict.accessor.DDictAccessor

class DDictAccessor[source]

Bases: object

Thin, error-handled wrapper around a raw Dragon DDict instance.

Parameters

ddict:

An attached DDict instance.

agent_id:

Identifier of the agent using this accessor (for log messages).

task_id:

Identifier of the current pipeline run (for log messages). May be empty when used by the orchestrator (no single task scope).

__init__(ddict: Any , agent_id: str = '', task_id: str = '') None [source]

Methods

__init__(ddict[, agent_id, task_id])

delete(key)

Remove a key from DDict.

get(key)

Read a value from DDict.

get_list(key)

Read a list from DDict, returning a mutable copy.

get_or_default(key[, default])

Read a value, returning default if the key does not exist.

put(key, value)

Write a value to DDict.

write_event(key_template, count_template, ...)

Write a numbered event and update the companion count key.

Attributes

raw

Return the underlying raw DDict instance.

__init__(ddict: Any , agent_id: str = '', task_id: str = '') None [source]
get(key: str ) Any [source]

Read a value from DDict.

Raises

Exception

If the DDict read fails for any reason. The original exception is logged at ERROR level and re-raised.

put(key: str , value: Any ) None [source]

Write a value to DDict.

Raises

Exception

If the DDict write fails. The original exception is logged at ERROR level and re-raised.

delete(key: str ) None [source]

Remove a key from DDict.

Raises

Exception

If the DDict delete fails. The original exception is logged at ERROR level and re-raised.

get_or_default(key: str , default: Any = None) Any [source]

Read a value, returning default if the key does not exist.

Unlike get(), a KeyError is not raised — the caller receives default instead. Other DDict failures are still raised.

get_list(key: str ) list [source]

Read a list from DDict, returning a mutable copy.

Ensures the caller gets a Python list that is safe to mutate without affecting the DDict entry.

write_event(key_template: str , count_template: str , event_data: Any , index: int , **fmt) None [source]

Write a numbered event and update the companion count key.

This deduplicates the identical pattern used for LLM, tool, HITL, and memory events in ToolDispatcher.chat().

Parameters

key_template:

Event key template (e.g. LLM_EVENT_KEY).

count_template:

Count key template (e.g. LLM_EVENT_COUNT_KEY).

event_data:

The event payload to write.

index:

Zero-based event index.

**fmt:

Format kwargs (task_id, agent_id, dispatch_id).

property raw: Any

Return the underlying raw DDict instance.

Use sparingly — prefer get() / put() for error handling. Needed for operations like DDict.attach(), DDict.detach(), DDict.serialize(), DDict.destroy() that operate on the DDict object itself rather than a key-value pair.