Skip to content

Data Management ​

How data flows through AmritaCore: messages, memory, backends, and the DI contexts that carry state between workflow nodes.

Messages ​

TypeRole
MessageOne conversation message (role, content, tool_calls, reasoning_content)
ToolResultA tool's output, paired with its tool_call_id
SendMessageWrapThe working context: train + memory + user_query + end_messages
UniResponseNormalized LLM response (content, tool_calls, reasoning_content, usage)

SendMessageWrap is what strategies mutate — ctx.message.append(...) adds to end_messages, which unwrap() includes in the next request.

DI Contexts ​

Workflow nodes receive state via type-matched injection — each node declares parameters like loop: AgentLoopState and the interpreter injects the matching instance. Key contexts (all owned by ChatObject):

ContextCarries
SessionMetadatasession/stream ids, timestamps
MemoryContextruntime memory
AbilityStateconfig, preset, backend slots
GeneralInputuser input, train, template
WorkingStatethe SendMessageWrap
RespStateresponse + usage (the run's SessionUsageProxy ledger)
AgentLoopStatestrategy, call count, run_state
StrategyPayloadthe strategy factory
DatabackendOptionsbackend fetch/commit skip flags

In AmritaSense terms this is the standard dependency-injection mechanism — see sense.amritabot.com for the general rules.

Cost Accounting ​

Every provider request that reports usage appends a BillingRecord to a run-scoped ledger (SessionUsageProxy on RespState). At the end of the run those records are copied into MemoryModel.billing, which is the default persistence path — so a memory backend that stores the whole MemoryModel already stores the cost history. A BillingBackend is only needed to mirror the same records somewhere else.

Each record carries the model, the preset name, and the RateConfig that applied at request time. AmritaCore deliberately stops there: it stores the rate and the token counts and lets consumers derive currency, so a later price change never rewrites history. See Data Backend and BillingRecord.

Two Deep-Dives ​

PageCovers
Data BackendThe AbilityBackend / MemoryBackend / BillingBackend interfaces, and how to write your own
Memory ModelMemoryModel, the load/commit lifecycle, and history compaction

Next ​

Extensions & Integration — adapters, tools and MCP.

Apache 2.0 License