-
Notifications
You must be signed in to change notification settings - Fork 29
feat(agentic idp): First version of agentic IDP using strands #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(agentic idp): First version of agentic IDP using strands #48
Conversation
cd18bbb
to
c3345ea
Compare
c3345ea
to
e2580e0
Compare
239141a
to
99565e2
Compare
99565e2
to
6e9e5db
Compare
- system_prompt | ||
- task_prompt | ||
properties: | ||
agentic: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do prompts work.. Does the agent still use the existing System prompt and Task prompt? (I had imagined the agent would need different prompt variants, but if not, that's great!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How Prompts Work with Agentic Extraction
The agentic extraction uses the existing System and Task prompts, but in a different way than traditional extraction:
Traditional Extraction
System prompt: Sent directly to Bedrock as system message
Task prompt: Sent as user message
Model responds with JSON text that needs parsing
Agentic Extraction
System prompt → Passed via custom_instruction parameter and appended to agentic system prompt
Task prompt → Sent as user message (content blocks with text/images)
Uses Strands agent with tools for structured output
No JSON parsing needed - returns validated Pydantic model
Key Difference
The agentic system prompt (in agentic_idp.py) provides extraction guidelines and tool usage instructions. Your existing system/task prompts are incorporated as custom instructions to guide the extraction without changing the core agent behavior.
eabe44b
to
4b23c91
Compare
How Prompts Work with Agentic ExtractionThe agentic extraction uses the existing System and Task prompts, but in a different way than traditional extraction: Traditional Extraction
Agentic Extraction
Key DifferenceThe agentic system prompt (in Result: Same prompts work for both methods, just applied differently under the hood. |
9b9c42b
to
db43335
Compare
d2373c5
to
83fd4a8
Compare
patterns/pattern-2/template.yaml
Outdated
description: This introduces a second agent to review the first agents work. Only use with highly complex workflows as it increases token usage. | ||
order: 1 | ||
default: false | ||
enable_caching: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to automate this.. already in idp_common bedrock client we have a list of models that support caching, so use that to auto detect and cache if model supports it.
docs/extraction.md
Outdated
|
||
Configure extraction behavior through several components: | ||
|
||
### Agentic Extraction (Recommended for Production) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it too soon to say this.. Better to say (Preview) or (Experimental) for now, IMHO, till we have more testing and ironed out bugs..
|
||
#### When to Enable Agentic Extraction | ||
|
||
Enable agentic extraction when you need: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say something about this enabling future extensions involving MCP servers to integrate validation or enrichment into the extraction process... (eg validate names, addresses, etc from external services)
When a field is not present, indicate this explicitly rather than guessing. | ||
task_prompt: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain how the system_prompt and task_prompts apply to the agentic extraction.. Does the agent use the same prompt as 'traditional' method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See slack comment on throttle catching..
it failed with
Execution Failed
Error: ValueError: Agent invocation failed: An error occurred (ThrottlingException) when calling the ConverseStream operation (reached max retries: 4): Too many tokens, please wait before trying again.
We need to keep retrying... for much much longer.. @kaznb can you check
idp_common bedrock client for exponential backoff/retry logic
state machine for retries at lambda invocation level..
We should never fail due to throttling.. at least not for several hours..
Note - I seem to get this error every time with Sonnet 4.5 in my isengard account when processing just 1 lending_package.pdf (Isengard has really low quota), but, whatever the customer quota is, we still need to defend against throttling when volumes are large and demand exceeds quota
1de7a71
to
b4c1f69
Compare
feat(agentic idp): First version of agentic IDP using strands
b4c1f69
to
8a23073
Compare
Summary
• Add agentic extraction module using Strands agents for structured data output without JSON parsing errors • Enhance
extraction service with dynamic Pydantic model generation from configuration attributes • Maintain full backward
compatibility - traditional extraction remains default behavior
Changes Made
• New: lib/idp_common_pkg/idp_common/extraction/agentic_idp.py - Core agentic functionality with tool-based
extraction
• Modified: lib/idp_common_pkg/idp_common/extraction/service.py - Added dynamic model generation and agentic
integration
• Updated: lib/idp_common_pkg/idp_common/extraction/README.md - Comprehensive documentation with usage examples
Benefits
• Eliminates JSON parsing errors through validated Pydantic models
• Improves extraction accuracy with self-correcting agent tools
• Provides dual extraction paths (traditional vs agentic) based on configuration
• Zero breaking changes - existing workflows continue unchanged
This enhancement significantly improves extraction reliability while preserving all existing functionality and
configuration patterns.