ConversationStore#

class ansys.cfx.mcp.common.conversation.ConversationStore(*, ttl_seconds: float = 60 * 60, max_entries: int = 256)#

Thread-safe TTL-bounded conversation store.

Overview#

create

Create and store a new code-generation conversation entry.

get

Return an existing conversation entry by session identifier.

get_or_create

Return an existing conversation entry or create a new one.

touch

Refresh the last-used time for a conversation entry.

append_history

Append one message to a conversation history.

set_pending_clarification

Record the clarification currently awaiting a user answer.

has_pending_clarification_id

Return whether a conversation is waiting for a specific clarification.

clarification_was_just_asked

Return whether a clarification was asked very recently.

Import detail#

from ansys.cfx.mcp.common.conversation import ConversationStore

Method detail#

ConversationStore.create() ConversationEntry#

Create and store a new code-generation conversation entry.

Returns:
ConversationEntry

Value computed by the helper for the requested CFX workflow.

ConversationStore.get(session_id: str) ConversationEntry | None#

Return an existing conversation entry by session identifier.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

Returns:
Optional[ConversationEntry]

Value computed by the helper for the requested CFX workflow.

ConversationStore.get_or_create(session_id: str | None) ConversationEntry#

Return an existing conversation entry or create a new one.

Parameters:
session_idOptional[str]

Conversation identifier used to retrieve or continue context.

Returns:
ConversationEntry

Requested CFX data or metadata for the active session.

ConversationStore.touch(session_id: str) None#

Refresh the last-used time for a conversation entry.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

Returns:
None

No value is returned; side effects are applied to the relevant cache, session, or server.

ConversationStore.append_history(session_id: str, role: str, content: Any) None#

Append one message to a conversation history.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

rolestr

Conversation message role, such as user or assistant.

contentAny

Conversation message content to store.

Returns:
None

No value is returned; side effects are applied to the relevant cache, session, or server.

ConversationStore.set_pending_clarification(session_id: str, clarification: dict[str, Any] | None) None#

Record the clarification currently awaiting a user answer.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

clarificationdict[str, Any] | None

Clarification payload currently waiting for a user answer.

Returns:
None

No value is returned; side effects are applied to the relevant cache, session, or server.

ConversationStore.has_pending_clarification_id(session_id: str, clarification_id: str) bool#

Return whether a conversation is waiting for a specific clarification.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

clarification_idstr

Identifier of the clarification being answered or checked.

Returns:
bool

Boolean answer for the requested condition.

ConversationStore.clarification_was_just_asked(session_id: str, question_text: str) bool#

Return whether a clarification was asked very recently.

Parameters:
session_idstr

Conversation identifier used to retrieve or continue context.

question_textstr

Clarification question text shown to the user.

Returns:
bool

Boolean answer for the requested condition.