Skip to content

Commit a6b4c19

Browse files
fix: strip server-managed AI usage tags from notebooks during sync
The Notebooks API now injects ai_generated, ai_edited, and human_edited tags on every write based on request characteristics. Since the sync CLI uses API key auth (not MCP), every PUT is classified as a human edit, causing human_edited:true to be added server-side. This creates a non-converging diff because the source notebook lacks the tag while the destination always gets it re-injected. Strip these server-managed tags in handle_special_case_attr so they are ignored on both sides during import, sync, and diff. Legitimate user tags (team:*, llm-observability:*) are unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3a878c7 commit a6b4c19

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

datadog_sync/model/notebooks.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,20 @@ async def delete_resource(self, _id: str) -> None:
8888
self.resource_config.base_path + f"/{self.config.state.destination[self.resource_type][_id]['id']}"
8989
)
9090

91+
# Server-managed AI usage tag keys injected by the Notebooks API on every write.
92+
# These reflect per-org interaction history (MCP vs human), not notebook content,
93+
# and must be stripped to avoid non-converging diffs during sync.
94+
_ai_usage_tag_keys = frozenset({"ai_generated", "ai_edited", "human_edited"})
95+
9196
@staticmethod
9297
def handle_special_case_attr(resource):
9398
# Handle template_variables attribute
9499
if "template_variables" in resource["attributes"] and not resource["attributes"]["template_variables"]:
95100
resource["attributes"].pop("template_variables")
101+
102+
# Strip server-managed AI usage tags
103+
tags = resource["attributes"].get("tags")
104+
if tags:
105+
resource["attributes"]["tags"] = [
106+
t for t in tags if t.split(":")[0] not in Notebooks._ai_usage_tag_keys
107+
]

0 commit comments

Comments
 (0)