Inspiration

Vendor due diligence is a messy, repetitive workflow. Teams often review privacy policies, service terms, security documentation, retention clauses, ownership terms, subprocessors, and commercial conditions manually.

Large language models can accelerate that work, but they introduce a serious trust problem: a model can produce a convincing explanation while quoting evidence incorrectly, attributing it to the wrong document, or presenting an interpretation as established fact.

Counterparty Gate was built around one question:

What if AI could do the heavy analytical work, while deterministic rules forced every important finding back to verifiable evidence?

What it does

Counterparty Gate is an agentic vendor due-diligence workflow.

A user supplies vendor documents. Gemini analyzes those documents and proposes potential diligence findings. Counterparty Gate then independently verifies whether each quoted piece of evidence actually exists in the attributed source.

The workflow separates two ideas that are often incorrectly merged:

  • Evidence verification: Does this exact quote exist in the supplied source?
  • Interpretation verification: Is the model's explanation of that quote definitely correct?

Verified quotes receive QUOTE_VERIFIED, while the model's interpretation remains REQUIRES_HUMAN_REVIEW.

The system also generates source-backed follow-up questions and prepares a diligence email draft. External action remains behind a human approval gate, represented by approval_required: true.

This makes the workflow:

Gemini reasons → deterministic rules verify → humans approve.

How we built it

Counterparty Gate uses:

  • Gemini 3.5 Flash
  • Google GenAI SDK (google-genai)
  • FastAPI
  • Google Cloud Run
  • Google Secret Manager
  • Google Cloud Build
  • Google Artifact Registry
  • A dedicated Google Cloud runtime service account
  • Python

The FastAPI application runs on Cloud Run.

Gemini handles document reasoning and structured finding generation. After Gemini returns proposed findings, deterministic application logic checks whether every cited quote exists in the exact source document attributed by the model.

If the evidence cannot be verified, the finding fails closed rather than being silently accepted.

The Gemini API credential is stored in Google Secret Manager and injected into the Cloud Run service at runtime. The service runs using a dedicated runtime identity with access scoped to the required secret.

For the hackathon demo, the Cloud Run service remains private and is accessed through an authenticated Google Cloud proxy.

Agentic workflow

Counterparty Gate goes beyond a simple chat interface.

The workflow performs several coordinated steps:

  1. Accept vendor documents.
  2. Ask Gemini to analyze them for diligence risks.
  3. Extract structured findings and supporting evidence.
  4. Independently verify each evidence quote against its attributed document.
  5. Separate verified evidence from unverified model interpretation.
  6. Generate supported follow-up questions.
  7. Prepare a diligence email draft.
  8. Require human approval before any external action.

This makes the system a Taskmaster-style workflow rather than a text-generation chatbot.

Evidence and safety design

A major design decision was that the model must not certify its own evidence.

During validation we tested cases including:

  • exact supplied evidence
  • fabricated evidence quotes
  • incorrect source attribution
  • separating quote verification from interpretation validity
  • excluding unsupported follow-up questions from the diligence email

The system is designed to fail closed when evidence cannot be supported.

Demo data

The hackathon demonstration uses a completely synthetic vendor named Northstar Demo Software.

No confidential customer, company, or proprietary third-party data is required for the demonstration.

Challenges

The hardest problem was not getting Gemini to produce useful analysis.

The harder problem was deciding what the application should trust after Gemini responds.

We discovered that verifying the existence of a quote does not automatically validate the model's interpretation of that quote. That led us to explicitly separate evidence status from interpretation status.

Another challenge was deploying the application without exposing credentials. We addressed this using Google Secret Manager and a dedicated Cloud Run runtime identity rather than embedding API keys in source code or deployment files.

What we learned

The most important learning was that reliable agentic systems need more than strong reasoning models.

They need clearly defined trust boundaries.

An LLM can be excellent at identifying patterns and proposing findings, while deterministic software can be better suited for checking exact evidence, enforcing workflow rules, and deciding when the system must stop and ask for human review.

The goal is not to make AI appear more certain.

The goal is to make AI accountable to evidence.

Current scope

Counterparty Gate is a hackathon prototype and validation build.

The current implementation demonstrates the core evidence-gated diligence workflow, real Gemini integration, Cloud Run deployment, deterministic evidence verification, and human approval boundary.

It is not presented as a production-ready legal, security, or compliance decision system.

What's next

Future development could include:

  • asynchronous multi-document processing
  • persistent diligence cases
  • richer contract and security-document parsers
  • reviewer dashboards
  • approval history and audit trails
  • organization-specific diligence policies
  • controlled integrations with email and procurement systems
  • stronger adversarial and prompt-injection testing
  • multi-user authorization and tenant isolation

The central principle will remain unchanged:

Gemini reasons. Deterministic rules verify. Humans approve.

Built With

Share this project:

Updates

Submission history