Skip to content

Commit 8d98dfd

Browse files
authored
Agentic extraction better retry (#138)
* bedrock utils for retry * invoke extraction with long retries * caching the first prompt * add review agent model config * refactor extraction service * fix pipeline ci failure * deps * bug fixes * pydantic validator update * pass the linting * default to empty string * deps fix * disable ci comments * fixes * json mode for model dump * add additional retryable errors * additional retryable errors * linting fix
1 parent 0d2e5a9 commit 8d98dfd

File tree

12 files changed

+2302
-1132
lines changed

12 files changed

+2302
-1132
lines changed

.github/workflows/developer-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
6060
- name: Install Node.js and basedpyright
6161
run: |
62-
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
62+
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
6363
apt-get install -y nodejs
6464
npm install -g basedpyright
6565
@@ -104,6 +104,7 @@ jobs:
104104
with:
105105
files: lib/idp_common_pkg/test-reports/test-results.xml
106106
check_name: Test Results
107+
comment_mode: off # Disable PR comments to avoid permission issues on fork PRs
107108

108109
- name: Code Coverage Report
109110
uses: irongut/CodeCoverageSummary@v1.3.0

config_library/pattern-2/lending-package-sample/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ agents:
18111811
parameters:
18121812
max_log_events: 5
18131813
time_range_hours_default: 24
1814-
1814+
18151815
chat_companion:
18161816
model_id: us.anthropic.claude-haiku-4-5-20251001-v1:0
18171817
pricing:

lib/idp_common_pkg/idp_common/config/models.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919
"""
2020

2121
from typing import Any, Dict, List, Optional, Union, Literal, Annotated
22-
from pydantic import BaseModel, ConfigDict, Field, field_validator, Discriminator
22+
from typing_extensions import Self
23+
from pydantic import (
24+
BaseModel,
25+
ConfigDict,
26+
Field,
27+
field_validator,
28+
Discriminator,
29+
model_validator,
30+
)
2331

2432

2533
class ImageConfig(BaseModel):
@@ -78,6 +86,10 @@ class AgenticConfig(BaseModel):
7886

7987
enabled: bool = Field(default=False, description="Enable agentic extraction")
8088
review_agent: bool = Field(default=False, description="Enable review agent")
89+
review_agent_model: str | None = Field(
90+
default=None,
91+
description="Model used for reviewing and correcting extraction work",
92+
)
8193

8294

8395
class ExtractionConfig(BaseModel):
@@ -120,6 +132,14 @@ def parse_int(cls, v: Any) -> int:
120132
return int(v) if v else 0
121133
return int(v)
122134

135+
@model_validator(mode="after")
136+
def set_default_review_agent_model(self) -> Self:
137+
"""Set review_agent_model to extraction model if not specified."""
138+
if not self.agentic.review_agent_model:
139+
self.agentic.review_agent_model = self.model
140+
141+
return self
142+
123143

124144
class ClassificationConfig(BaseModel):
125145
"""Document classification configuration"""
@@ -423,7 +443,7 @@ class ErrorAnalyzerConfig(BaseModel):
423443
"AccessDenied",
424444
"ThrottlingException",
425445
],
426-
description="Error patterns to search for in logs"
446+
description="Error patterns to search for in logs",
427447
)
428448
system_prompt: str = Field(
429449
default="""
@@ -511,11 +531,10 @@ class ErrorAnalyzerConfig(BaseModel):
511531
- No time specified: 24 hours (default)
512532
513533
IMPORTANT: Do not include any search quality reflections, search quality scores, or meta-analysis sections in your response. Only provide the three required sections: Root Cause, Recommendations, and Evidence.""",
514-
description="System prompt for error analyzer"
534+
description="System prompt for error analyzer",
515535
)
516536
parameters: ErrorAnalyzerParameters = Field(
517-
default_factory=ErrorAnalyzerParameters,
518-
description="Error analyzer parameters"
537+
default_factory=ErrorAnalyzerParameters, description="Error analyzer parameters"
519538
)
520539

521540

@@ -635,12 +654,10 @@ class AgentsConfig(BaseModel):
635654
"""Agents configuration"""
636655

637656
error_analyzer: Optional[ErrorAnalyzerConfig] = Field(
638-
default_factory=ErrorAnalyzerConfig,
639-
description="Error analyzer configuration"
657+
default_factory=ErrorAnalyzerConfig, description="Error analyzer configuration"
640658
)
641659
chat_companion: Optional[ChatCompanionConfig] = Field(
642-
default_factory=ChatCompanionConfig,
643-
description="Chat companion configuration"
660+
default_factory=ChatCompanionConfig, description="Chat companion configuration"
644661
)
645662

646663

0 commit comments

Comments
 (0)