dragon.ai.agent.ddict.accessor.DDictAccessor
- class DDictAccessor[source]
Bases:
objectThin, error-handled wrapper around a raw Dragon DDict instance.
Parameters
- ddict:
An attached
DDictinstance.- 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).
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
Return the underlying raw DDict instance.
- 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(), aKeyErroris 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
listthat 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).