[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot]
2026-05-25 05:52:44 +00:00
committed by GitHub
parent 943b23b042
commit 3d89fb444c
4 changed files with 24 additions and 7 deletions

View File

@ -31,9 +31,7 @@ class PydanticAIHistoryRuntimeState(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid", validate_assignment=True)
class PydanticAIHistoryLayer(
PydanticAILayer[NoLayerDeps, object, EmptyLayerConfig, PydanticAIHistoryRuntimeState]
):
class PydanticAIHistoryLayer(PydanticAILayer[NoLayerDeps, object, EmptyLayerConfig, PydanticAIHistoryRuntimeState]):
"""State-only layer that stores pydantic-ai message history.
The mutable history lives only in ``runtime_state.messages``. Helper methods

View File

@ -47,4 +47,5 @@ class DifyOutputLayerConfig(LayerConfig):
raise ValueError("Schema must declare an object output.")
return value
__all__ = ["DIFY_OUTPUT_LAYER_TYPE_ID", "DifyOutputLayerConfig"]

View File

@ -187,6 +187,8 @@ def _build_exposed_json_schema(
if description is not None:
exposed_schema["description"] = description
return exposed_schema
def _reject_non_local_refs(schema: JsonValue) -> None:
"""Reject references that would require external fetching or non-local state.

View File

@ -5,7 +5,15 @@ from typing import Any
import httpx
import pytest
from pydantic_ai.exceptions import UnexpectedModelBehavior
from pydantic_ai.messages import ModelMessage, ModelRequest, ModelResponse, SystemPromptPart, TextPart, ToolCallPart, UserPromptPart
from pydantic_ai.messages import (
ModelMessage,
ModelRequest,
ModelResponse,
SystemPromptPart,
TextPart,
ToolCallPart,
UserPromptPart,
)
from pydantic_ai.models import ModelRequestParameters
from pydantic_ai.models.test import TestModel
from pydantic_ai.settings import ModelSettings
@ -163,11 +171,15 @@ def _history_session_snapshot(
runtime_state=PydanticAIHistoryRuntimeState(messages=messages).model_dump(mode="json"),
),
LayerSessionSnapshot(name="plugin", lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),
LayerSessionSnapshot(name=DIFY_AGENT_MODEL_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),
LayerSessionSnapshot(
name=DIFY_AGENT_MODEL_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}
),
]
if include_output:
layers.append(
LayerSessionSnapshot(name=DIFY_AGENT_OUTPUT_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={})
LayerSessionSnapshot(
name=DIFY_AGENT_OUTPUT_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}
)
)
return CompositorSessionSnapshot(layers=layers)
@ -257,7 +269,11 @@ def test_runner_passes_temporary_system_prompt_prefix_without_history_layer(monk
assert request_parts[1].content == "current user"
terminal = sink.events["run-no-history"][-1]
assert isinstance(terminal, RunSucceededEvent)
assert [layer.name for layer in terminal.data.session_snapshot.layers] == ["prompt", "plugin", DIFY_AGENT_MODEL_LAYER_ID]
assert [layer.name for layer in terminal.data.session_snapshot.layers] == [
"prompt",
"plugin",
DIFY_AGENT_MODEL_LAYER_ID,
]
def test_runner_prepends_current_system_prompt_to_stored_history_and_appends_only_new_messages(