Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Add meaningful change support to monitors

Developers Digest41d455552251
diff --git a/apps/go-sdk/models.go b/apps/go-sdk/models.go
index 23ec7625f..858bfcce9 100644
--- a/apps/go-sdk/models.go
+++ b/apps/go-sdk/models.go
@@ -227,14 +227,23 @@ type MonitorPageSnapshot struct {
JSON map[string]interface{} `json:"json,omitempty"`
}
+// MonitorMeaningfulChange is a single goal-relevant change selected by the
+// monitor judge.
+type MonitorMeaningfulChange struct {
+ Type string `json:"type"`
+ Before *string `json:"before"`
+ After *string `json:"after"`
+ Reason string `json:"reason"`
+}
+
// MonitorPageJudgment is the judge's verdict on whether a page change is
// meaningful. Populated on monitor check pages when the monitor has a
// goal set and judging is enabled.
type MonitorPageJudgment struct {
- Meaningful bool `json:"meaningful"`
- Confidence string `json:"confidence"`
- Reason string `json:"reason"`
- Fields []string `json:"fields"`
+ Meaningful bool `json:"meaningful"`
+ Confidence string `json:"confidence"`
+ Reason string `json:"reason"`
+ MeaningfulChanges []MonitorMeaningfulChange `json:"meaningfulChanges"`
}
// MonitorCheckPage is a single page result in a monitor check.
diff --git a/apps/go-sdk/monitor_models_test.go b/apps/go-sdk/monitor_models_test.go
new file mode 100644
index 000000000..ac41c62a3
--- /dev/null
+++ b/apps/go-sdk/monitor_models_test.go
@@ -0,0 +1,38 @@
+package firecrawl
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestMonitorPageJudgmentParsesMeaningfulChanges(t *testing.T) {
+ payload := []byte(`{
+ "meaningful": true,
+ "confidence": "high",
+ "reason": "The tracked price changed.",
+ "meaningfulChanges": [
+ {
+ "type": "changed",
+ "before": "$10",
+ "after": "$12",
+ "reason": "Price increased."
+ }
+ ]
+ }`)
+
+ var judgment MonitorPageJudgment
+ if err := json.Unmarshal(payload, &judgment); err != nil {
+ t.Fatalf("Unmarshal MonitorPageJudgment: %v", err)
+ }
+
+ if !judgment.Meaningful || judgment.Confidence != "high" {
+ t.Fatalf("judgment = %+v", judgment)
+ }
+ if len(judgment.MeaningfulChanges) != 1 {
+ t.Fatalf("meaningfulChanges length = %d, want 1", len(judgment.MeaningfulChanges))
+ }
+ change := judgment.MeaningfulChanges[0]
+ if change.Type != "changed" || change.Before == nil || *change.Before != "$10" || change.After == nil || *change.After != "$12" {
+ t.Fatalf("meaningful change = %+v", change)
+ }
+}
diff --git a/apps/python-sdk/firecrawl/__tests__/unit/v2/test_monitor_types.py b/apps/python-sdk/firecrawl/__tests__/unit/v2/test_monitor_types.py
new file mode 100644
index 000000000..9d6388f62
--- /dev/null
+++ b/apps/python-sdk/firecrawl/__tests__/unit/v2/test_monitor_types.py
@@ -0,0 +1,22 @@
+from firecrawl.v2.types import MonitorPageJudgment
+
+
+def test_monitor_page_judgment_parses_meaningful_changes():
+ judgment = MonitorPageJudgment.model_validate(
+ {
+ "meaningful": True,
+ "confidence": "high",
+ "reason": "The tracked price changed.",
+ "meaningfulChanges": [
+ {
+ "type": "changed",
+ "before": "$10",
+ "after": "$12",
+ "reason": "Price increased.",
+ }
+ ],
+ }
+ )
+
+ assert judgment.meaningful is True
+ assert judgment.meaningful_changes[0].type == "changed"
diff --git a/apps/python-sdk/firecrawl/v2/types.py b/apps/python-sdk/firecrawl/v2/types.py
index a9a0bcb4a..43934bec0 100644
--- a/apps/python-sdk/firecrawl/v2/types.py
+++ b/apps/python-sdk/firecrawl/v2/types.py
@@ -947,11 +947,21 @@ class Monitor(BaseModel):
updated_at: str = Field(alias="updatedAt")
+class MonitorMeaningfulChange(BaseModel):
+ type: Literal["added", "removed", "changed"]
+ before: Optional[str] = None
+ after: Optional[str] = None
+ reason: str
+
+
class MonitorPageJudgment(BaseModel):
+ model_config = {"populate_by_name": True}
+
meaningful: bool
confidence: Literal["high", "medium", "low"]
reason: str
fields: List[str]
+ meaningful_changes: List[MonitorMeaningfulChange] = Field(default_factory=list, alias="meaningfulChanges")
class MonitorCheck(BaseModel):