Files
AutoGPT/rnd/autogpt_server/migrations/20240729051155_static_input_link/migration.sql
Zamil Majdy 29ba4c2c73 feat(rnd): Add freezed/static input link feature for retaining input data to be re-used in multiple node executions (#7631)
### Background

Input from the input pin is consumed only once. While this is required in most of the use cases, there are some cases where the input can only be produced once, and that input needs to be re-used just like an input default value, that is passively providing input data, without triggering any execution. The scope of this change is providing that functionality in the link level, this property will be called **`static link`** in this system.

### Changes 🏗️

Provides a static link feature with the following behaviours:
* A link can be marked `static` to become a static link.
* Once a node produces an output it will persist the output data and propagate the output to the other nodes through the link, for a static link, instead of making the data queued in the input pin, it will override the default value.
* Any input executions still waiting for the input will be backfilled using this output produced by the static link.
* And any upcoming executions that will use the input will always reuse the output produced by the static link.

See the added test to see the expected usage.
2024-07-30 10:37:38 +07:00

21 lines
1.0 KiB
SQL

-- AlterTable
ALTER TABLE "AgentNodeExecution" ADD COLUMN "executionData" TEXT;
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_AgentNodeLink" (
"id" TEXT NOT NULL PRIMARY KEY,
"agentNodeSourceId" TEXT NOT NULL,
"sourceName" TEXT NOT NULL,
"agentNodeSinkId" TEXT NOT NULL,
"sinkName" TEXT NOT NULL,
"isStatic" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "AgentNodeLink_agentNodeSourceId_fkey" FOREIGN KEY ("agentNodeSourceId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "AgentNodeLink_agentNodeSinkId_fkey" FOREIGN KEY ("agentNodeSinkId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_AgentNodeLink" ("agentNodeSinkId", "agentNodeSourceId", "id", "sinkName", "sourceName") SELECT "agentNodeSinkId", "agentNodeSourceId", "id", "sinkName", "sourceName" FROM "AgentNodeLink";
DROP TABLE "AgentNodeLink";
ALTER TABLE "new_AgentNodeLink" RENAME TO "AgentNodeLink";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;