core.response_context
Shared prompt attribute history with thread-safe recording.
Shared prompt attribute history with thread-safe recording.
- class ResponseContext(shared_prompt_attr_history=None, history_lock=None)[source]
Bases:
objectManages the shared
prompt_attr_historylist with thread-safe recording.This class centralises all mutation of the shared prompt-attribute history that
PromptBuilderreads from for{{name.response}}interpolation. It replaces the inline history recording previously scattered throughFFAI.generate_response()and direct list appends inPlanningRunner/SynthesisRunner.- Parameters:
shared_prompt_attr_history (list[dict[str, Any]] | None) – Optional pre-existing list to share. When
Nonea new empty list is created.history_lock (threading.Lock | None) – Optional lock for thread-safe access.
- record(prompt, response, model, prompt_name=None, history=None)[source]
Record an interaction to
prompt_attr_history.If response is a
dict(JSON response from the LLM), each top-level key-value pair is recorded as a separate entry so that{{key_name.response}}interpolation works.- Parameters:
prompt (str) – The original prompt text (or JSON key name).
response (Any) – The cleaned response (str, dict, etc.).
model (str) – Model identifier used for this call.
prompt_name (str | None) – Optional logical name for the prompt.
history (list[str] | None) – Optional list of history dependency names.
- Return type:
None
- record_raw(interaction)[source]
Append a pre-built interaction dict.
Used by
PlanningRunnerandSynthesisRunnerto inject results that were not produced byFFAI.generate_response().
- property history_lock: threading.Lock | None
The lock used for thread-safe history access.
Classes
- class ResponseContext(shared_prompt_attr_history=None, history_lock=None)[source]
Bases:
objectManages the shared
prompt_attr_historylist with thread-safe recording.This class centralises all mutation of the shared prompt-attribute history that
PromptBuilderreads from for{{name.response}}interpolation. It replaces the inline history recording previously scattered throughFFAI.generate_response()and direct list appends inPlanningRunner/SynthesisRunner.- Parameters:
shared_prompt_attr_history (list[dict[str, Any]] | None) – Optional pre-existing list to share. When
Nonea new empty list is created.history_lock (threading.Lock | None) – Optional lock for thread-safe access.
- record(prompt, response, model, prompt_name=None, history=None)[source]
Record an interaction to
prompt_attr_history.If response is a
dict(JSON response from the LLM), each top-level key-value pair is recorded as a separate entry so that{{key_name.response}}interpolation works.- Parameters:
prompt (str) – The original prompt text (or JSON key name).
response (Any) – The cleaned response (str, dict, etc.).
model (str) – Model identifier used for this call.
prompt_name (str | None) – Optional logical name for the prompt.
history (list[str] | None) – Optional list of history dependency names.
- Return type:
None
- record_raw(interaction)[source]
Append a pre-built interaction dict.
Used by
PlanningRunnerandSynthesisRunnerto inject results that were not produced byFFAI.generate_response().
- property history_lock: threading.Lock | None
The lock used for thread-safe history access.