From 5baf1a0f60e5b357a80a8d8f7497eecb93bfa12b Mon Sep 17 00:00:00 2001 From: Bentlybro Date: Fri, 13 Feb 2026 14:48:21 +0000 Subject: [PATCH] Use NotGiven sentinels and add migration timestamps Update LLM integrations and migration to match SDK and schema changes: switch from anthropic.omit/openai.Omit types to anthropic.NOT_GIVEN/openai.NotGiven in llm.py (and update type hints), stop converting createdAt/revertedAt to ISO strings in DB mapping to preserve datetime types, and add createdAt/updatedAt (NOW()) to LlmModel and LlmModelCost inserts in the migration SQL so new rows populate timestamps. --- autogpt_platform/backend/backend/blocks/llm.py | 6 +++--- autogpt_platform/backend/backend/server/v2/llm/db.py | 4 ++-- .../migration.sql | 12 ++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.py index 87963e42eb..e1b54fca79 100644 --- a/autogpt_platform/backend/backend/blocks/llm.py +++ b/autogpt_platform/backend/backend/blocks/llm.py @@ -265,12 +265,12 @@ class LLMResponse(BaseModel): def convert_openai_tool_fmt_to_anthropic( openai_tools: list[dict] | None = None, -) -> Iterable[ToolParam] | anthropic.Omit: +) -> Iterable[ToolParam] | anthropic.NotGiven: """ Convert OpenAI tool format to Anthropic tool format. """ if not openai_tools or len(openai_tools) == 0: - return anthropic.omit + return anthropic.NOT_GIVEN anthropic_tools = [] for tool in openai_tools: @@ -330,7 +330,7 @@ def extract_openai_tool_calls(response) -> list[ToolContentBlock] | None: def get_parallel_tool_calls_param( llm_model: LlmModel, parallel_tool_calls: bool | None -) -> bool | openai.Omit: +) -> bool | openai.NotGiven: """Get the appropriate parallel_tool_calls parameter for OpenAI-compatible APIs.""" # Check for o-series models (o1, o1-mini, o3-mini, etc.) which don't support # parallel tool calls. Use regex to avoid false positives like "openai/gpt-oss". diff --git a/autogpt_platform/backend/backend/server/v2/llm/db.py b/autogpt_platform/backend/backend/server/v2/llm/db.py index 765aba3222..d6b1148894 100644 --- a/autogpt_platform/backend/backend/server/v2/llm/db.py +++ b/autogpt_platform/backend/backend/server/v2/llm/db.py @@ -614,8 +614,8 @@ def _map_migration( node_count=record.nodeCount, custom_credit_cost=record.customCreditCost, is_reverted=record.isReverted, - created_at=record.createdAt.isoformat(), - reverted_at=record.revertedAt.isoformat() if record.revertedAt else None, + created_at=record.createdAt, + reverted_at=record.revertedAt, ) diff --git a/autogpt_platform/backend/migrations/20260212000001_sync_llm_models_with_dev/migration.sql b/autogpt_platform/backend/migrations/20260212000001_sync_llm_models_with_dev/migration.sql index d8b1fda5fe..b846723f75 100644 --- a/autogpt_platform/backend/migrations/20260212000001_sync_llm_models_with_dev/migration.sql +++ b/autogpt_platform/backend/migrations/20260212000001_sync_llm_models_with_dev/migration.sql @@ -12,7 +12,7 @@ DELETE FROM "LlmModel" WHERE "slug" IN ('o3', 'o3-mini', 'claude-3-7-sonnet-2025 WITH provider_ids AS ( SELECT "id", "name" FROM "LlmProvider" ) -INSERT INTO "LlmModel" ("id", "slug", "displayName", "description", "providerId", "contextWindow", "maxOutputTokens", "isEnabled", "capabilities", "metadata") +INSERT INTO "LlmModel" ("id", "slug", "displayName", "description", "providerId", "contextWindow", "maxOutputTokens", "isEnabled", "capabilities", "metadata", "createdAt", "updatedAt") SELECT gen_random_uuid(), model_slug, @@ -23,7 +23,9 @@ SELECT max_output_tokens, true, '{}'::jsonb, - '{}'::jsonb + '{}'::jsonb, + NOW(), + NOW() FROM (VALUES -- New OpenAI model ('gpt-5.2-2025-12-11', 'GPT 5.2', 'openai', 400000, 128000), @@ -40,7 +42,7 @@ WITH model_ids AS ( provider_ids AS ( SELECT "id", "name" FROM "LlmProvider" ) -INSERT INTO "LlmModelCost" ("id", "unit", "creditCost", "credentialProvider", "credentialId", "credentialType", "currency", "metadata", "llmModelId") +INSERT INTO "LlmModelCost" ("id", "unit", "creditCost", "credentialProvider", "credentialId", "credentialType", "currency", "metadata", "llmModelId", "createdAt", "updatedAt") SELECT gen_random_uuid(), 'RUN'::"LlmCostUnit", @@ -50,7 +52,9 @@ SELECT 'api_key', NULL, '{}'::jsonb, - m."id" + m."id", + NOW(), + NOW() FROM (VALUES -- New model costs (estimate based on similar models) ('gpt-5.2-2025-12-11', 5), -- Similar to GPT 5.1