feat: add workflow_version to workflow_agent_node_bindings (#36603)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
zyssyz123
2026-05-25 06:26:19 +00:00
committed by GitHub
co-authored by Claude Opus 4.7 autofix-ci[bot]
parent eb41c9b769
commit 5f7eb7bde9
9 changed files with 121 additions and 11 deletions
+11
View File
@@ -28,6 +28,10 @@ from services.entities.agent_entities import (
WorkflowNodeJobConfig,
)
# WorkflowAgentNodeBinding.workflow_version tag for the draft workflow row.
# Mirrors Workflow.version when it is "draft" (see models/workflow.py).
_DRAFT_WORKFLOW_VERSION = "draft"
class AgentComposerService:
@classmethod
@@ -284,6 +288,7 @@ class AgentComposerService:
tenant_id=tenant_id,
app_id=app_id,
workflow_id=workflow_id,
workflow_version=_DRAFT_WORKFLOW_VERSION,
node_id=node_id,
binding_type=WorkflowAgentBindingType.INLINE_AGENT,
agent_id=agent.id,
@@ -387,6 +392,7 @@ class AgentComposerService:
tenant_id=tenant_id,
app_id=app_id,
workflow_id=workflow_id,
workflow_version=_DRAFT_WORKFLOW_VERSION,
node_id=node_id,
created_by=account_id,
)
@@ -606,11 +612,16 @@ class AgentComposerService:
def _get_workflow_binding(
cls, *, tenant_id: str, workflow_id: str, node_id: str
) -> WorkflowAgentNodeBinding | None:
# Composer always operates against the draft workflow row, so this lookup
# is scoped to ``workflow_version="draft"``. Published bindings are
# materialized by WorkflowAgentPublishService.copy_agent_node_bindings_to_published
# and are not edited through the Composer.
return db.session.scalar(
select(WorkflowAgentNodeBinding)
.where(
WorkflowAgentNodeBinding.tenant_id == tenant_id,
WorkflowAgentNodeBinding.workflow_id == workflow_id,
WorkflowAgentNodeBinding.workflow_version == _DRAFT_WORKFLOW_VERSION,
WorkflowAgentNodeBinding.node_id == node_id,
)
.limit(1)
@@ -39,6 +39,7 @@ class WorkflowAgentPublishService:
WorkflowAgentNodeBinding.tenant_id == draft_workflow.tenant_id,
WorkflowAgentNodeBinding.app_id == draft_workflow.app_id,
WorkflowAgentNodeBinding.workflow_id == draft_workflow.id,
WorkflowAgentNodeBinding.workflow_version == draft_workflow.version,
WorkflowAgentNodeBinding.node_id.in_(node_ids),
)
).all()
@@ -48,6 +49,7 @@ class WorkflowAgentPublishService:
tenant_id=binding.tenant_id,
app_id=binding.app_id,
workflow_id=published_workflow.id,
workflow_version=published_workflow.version,
node_id=binding.node_id,
binding_type=binding.binding_type,
agent_id=binding.agent_id,