Allow chat history to be sent to AI engine (#6128)

# Description of Changes
Add an extra parameter to every agent to receive the conversation
history in addition to the current message. This will make it possible
to answer followup questions from the AI without needing to give full
context in your message.
This commit is contained in:
James Brunton
2026-04-21 15:03:10 +00:00
committed by GitHub
parent f779085d75
commit 2a856fbc19
14 changed files with 116 additions and 19 deletions
@@ -18,6 +18,7 @@ from .common import (
SupportedCapability,
ToolOperationStep,
WorkflowOutcome,
format_conversation_history,
)
from .execution import (
AgentExecutionRequest,
@@ -104,6 +105,7 @@ __all__ = [
"Folio",
"FolioManifest",
"FolioType",
"format_conversation_history",
"HealthResponse",
"NeedContentFileRequest",
"NextExecutionAction",
+6
View File
@@ -91,6 +91,12 @@ class ConversationMessage(ApiModel):
content: str
def format_conversation_history(conversation_history: list[ConversationMessage]) -> str:
if not conversation_history:
return "None"
return "\n".join(f"- {message.role}: {message.content}" for message in conversation_history)
class PdfTextSelection(ApiModel):
page_number: int | None = None
text: str
@@ -7,7 +7,13 @@ from pydantic import Field
from stirling.models import ApiModel
from .agent_drafts import AgentDraftResponse
from .common import ArtifactKind, ExtractedFileText, SupportedCapability, WorkflowOutcome
from .common import (
ArtifactKind,
ConversationMessage,
ExtractedFileText,
SupportedCapability,
WorkflowOutcome,
)
from .execution import NextExecutionAction
from .pdf_edit import PdfEditResponse
from .pdf_questions import PdfQuestionResponse
@@ -24,6 +30,7 @@ WorkflowArtifact = Annotated[ExtractedTextArtifact, Field(discriminator="kind")]
class OrchestratorRequest(ApiModel):
user_message: str
file_names: list[str]
conversation_history: list[ConversationMessage] = Field(default_factory=list)
artifacts: list[WorkflowArtifact] = Field(default_factory=list)
resume_with: SupportedCapability | None = None
+2 -1
View File
@@ -6,12 +6,13 @@ from pydantic import Field
from stirling.models import ApiModel
from .common import ToolOperationStep, WorkflowOutcome
from .common import ConversationMessage, ToolOperationStep, WorkflowOutcome
class PdfEditRequest(ApiModel):
user_message: str
file_names: list[str] = Field(default_factory=list)
conversation_history: list[ConversationMessage] = Field(default_factory=list)
class EditPlanResponse(ApiModel):
@@ -6,13 +6,20 @@ from pydantic import Field
from stirling.models import ApiModel
from .common import ExtractedFileText, PdfContentType, SupportedCapability, WorkflowOutcome
from .common import (
ConversationMessage,
ExtractedFileText,
PdfContentType,
SupportedCapability,
WorkflowOutcome,
)
class PdfQuestionRequest(ApiModel):
question: str
page_text: list[ExtractedFileText] = Field(default_factory=list)
file_names: list[str]
conversation_history: list[ConversationMessage] = Field(default_factory=list)
class PdfQuestionAnswerResponse(ApiModel):