Code
!make setup
!make fetch_models
!make run
!make logfire_auth
!make populate_dbHere we will demonstrate agentic delegation where a central AI agent can delegate sub-tasks to other agents for a well-defined division of the work. While more complex than having a single AI agent, delegation can lead to better overall performance. Here we set up a political analyst agent to have access to a series of party expert agents (one for each party currently in the Danish parliament). The political analyst takes input from the user about their viewpoints and then queries relevant parties on their opinions in order to rank the parties according to their alignment with the user. This page is part of the chat_with_parliament repository which contains all the code for the demo.
Here we will demonstrate a multi-agent AI implementation. A political analyst agent takes input from users about their political views and which subjects matter to them.
For each party in the Danish parliament, a party expert agent is implemented with access to a vector database collection containing the relevant party’s manifesto. Under the hood there is actually only one party expert agent, it just filters the vector database according to which party it is asked about.
In an agentic delegation setup, the political analyst can choose to query one or more of the party expert agents on specific subjects. After having gathered the relevant responses from the party experts, the political analyst agent can score each of the parties in relation to their alignment with the user’s input.
Let’s start by running the setup with two statements in opposite directions valuing either climate change concerns or economic growth the highest.
Below we see the logs of the model run showing how the political analyst agent queries the individual party expert agents, the responses being sent back, and finally how political analyst compiles the answers. Further below we see the scores given to the individual parties by the political analyst.
!make setup
!make fetch_models
!make run
!make logfire_auth
!make populate_dbfrom backend.agents import political_analyst_agent
def print_party_scores(result):
print('Party Score Reason')
for recommendation in sorted(result.output.results, key=lambda x: x.score, reverse=True):
print(f'{recommendation.party_id:5} {recommendation.score:5} {recommendation.reason}')Logfire project URL: https://logfire-eu.pydantic.dev/crs17/chat-with-parliament
result_klima_1 = await political_analyst_agent.run(
"Klimaet er vigtigere end erhvervslivet! Lad mig se en score for alle partierne"
)14:14:40.762 political_analyst_agent run
14:14:40.769 chat claude-sonnet-4-5
14:14:49.016 running 12 tools
14:14:49.017 running tool: consult_party_expert
>>> Analyst → Party Expert: Socialdemokratiet (A), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.018 party_expert_agent run
14:14:49.018 running tool: consult_party_expert
>>> Analyst → Party Expert: Radikale Venstre (B), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.018 party_expert_agent run
14:14:49.019 running tool: consult_party_expert
>>> Analyst → Party Expert: Det Konservative Folkeparti (C), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.019 party_expert_agent run
14:14:49.019 running tool: consult_party_expert
>>> Analyst → Party Expert: SF - Socialistisk Folkeparti (F), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.020 party_expert_agent run
14:14:49.020 running tool: consult_party_expert
>>> Analyst → Party Expert: Borgernes Parti - Lars Boje Mathiesen (H), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.020 party_expert_agent run
14:14:49.020 running tool: consult_party_expert
>>> Analyst → Party Expert: Liberal Alliance (I), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.021 party_expert_agent run
14:14:49.021 running tool: consult_party_expert
>>> Analyst → Party Expert: Dansk Folkeparti (O), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.022 party_expert_agent run
14:14:49.022 running tool: consult_party_expert
>>> Analyst → Party Expert: Moderaterne (M), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.022 party_expert_agent run
14:14:49.022 running tool: consult_party_expert
>>> Analyst → Party Expert: Venstre, Danmarks Liberale Parti (V), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.023 party_expert_agent run
14:14:49.023 running tool: consult_party_expert
>>> Analyst → Party Expert: Danmarksdemokraterne - Inger Støjberg (Æ), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.023 party_expert_agent run
14:14:49.023 running tool: consult_party_expert
>>> Analyst → Party Expert: Enhedslisten - De Rød-Grønne (Ø), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.024 party_expert_agent run
14:14:49.024 running tool: consult_party_expert
>>> Analyst → Party Expert: Alternativet (Å), query='klimapolitik og prioritering af klima over erhvervsinteresser'
14:14:49.024 party_expert_agent run
running tool: consult_party_expert
party_expert_agent run
14:14:49.026 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.027 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.029 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.030 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.031 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.032 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.033 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.033 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.034 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.035 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.036 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:49.037 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:50.750 running 1 tool
14:14:50.750 running tool: get_context
[RAG] Enhedslisten - De Rød-Grønne (Ø): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Enhedslisten - De Rød-Grønne
running tool: consult_party_expert
party_expert_agent run
14:14:52.680 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:14:52.680 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:14:52.680 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:14:52.681 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:14:52.681 running 3 tools
running tool: consult_party_expert
party_expert_agent run
14:14:52.681 running 3 tools
running tool: consult_party_expert
party_expert_agent run
14:14:52.681 running 3 tools
running tool: consult_party_expert
party_expert_agent run
14:14:52.682 running 3 tools
running tool: consult_party_expert
party_expert_agent run
14:14:52.682 running 3 tools
running tool: consult_party_expert
party_expert_agent run
14:14:52.682 running 3 tools
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:14:52.682 running tool: get_context
[RAG] Borgernes Parti - Lars Boje Mathiesen (H): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Borgernes Parti - Lars Boje Mathiesen
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:14:52.961 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:14:53.246 running tool: get_context
[RAG] Alternativet (Å): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Alternativet
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:14:53.554 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:53.826 running tool: get_context
[RAG] Moderaterne (M): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 0 chunks for Moderaterne
14:14:54.099 running tool: get_context
[RAG] Moderaterne (M): 'klima erhverv balance økonomi'
[RAG] Found 0 chunks for Moderaterne
14:14:54.349 running tool: get_context
[RAG] Moderaterne (M): 'grøn omstilling virksomheder konkurrenceevne'
[RAG] Found 0 chunks for Moderaterne
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:54.633 running tool: get_context
[RAG] Dansk Folkeparti (O): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Dansk Folkeparti
14:14:54.927 running tool: get_context
[RAG] Dansk Folkeparti (O): 'klima erhverv økonomi balance'
[RAG] Found 2 chunks for Dansk Folkeparti
14:14:55.200 running tool: get_context
[RAG] Dansk Folkeparti (O): 'klimamål CO2 reduktion erhvervsliv'
[RAG] Found 2 chunks for Dansk Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:55.489 running tool: get_context
[RAG] Venstre, Danmarks Liberale Parti (V): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Venstre, Danmarks Liberale Parti
14:14:55.782 running tool: get_context
[RAG] Venstre, Danmarks Liberale Parti (V): 'klima erhverv balance økonomi'
[RAG] Found 2 chunks for Venstre, Danmarks Liberale Parti
14:14:56.133 running tool: get_context
[RAG] Venstre, Danmarks Liberale Parti (V): 'grøn omstilling virksomheder konkurrenceevne'
[RAG] Found 2 chunks for Venstre, Danmarks Liberale Parti
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:56.387 running tool: get_context
[RAG] Liberal Alliance (I): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Liberal Alliance
14:14:56.672 running tool: get_context
[RAG] Liberal Alliance (I): 'klima erhverv økonomi balance'
[RAG] Found 2 chunks for Liberal Alliance
14:14:56.951 running tool: get_context
[RAG] Liberal Alliance (I): 'klimamål CO2 reduktion erhvervsliv'
[RAG] Found 2 chunks for Liberal Alliance
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:57.234 running tool: get_context
[RAG] Radikale Venstre (B): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Radikale Venstre
14:14:57.521 running tool: get_context
[RAG] Radikale Venstre (B): 'klima erhvervsliv økonomi balance'
[RAG] Found 2 chunks for Radikale Venstre
14:14:57.799 running tool: get_context
[RAG] Radikale Venstre (B): 'klimamål CO2 reduktion grøn omstilling'
[RAG] Found 2 chunks for Radikale Venstre
running tool: consult_party_expert
party_expert_agent run
running 3 tools
14:14:58.111 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:14:58.368 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'klima erhverv balance økonomi'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:14:58.662 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'grøn omstilling virksomheder konkurrenceevne'
[RAG] Found 0 chunks for Det Konservative Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:14:59.043 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.056 running 3 tools
14:14:59.057 running tool: get_context
[RAG] Socialdemokratiet (A): 'klimapolitik prioritering klima erhvervsinteresser'
[RAG] Found 2 chunks for Socialdemokratiet
14:14:59.326 running tool: get_context
[RAG] Socialdemokratiet (A): 'klima erhvervsliv balance økonomi'
[RAG] Found 2 chunks for Socialdemokratiet
14:14:59.579 running tool: get_context
[RAG] Socialdemokratiet (A): 'grøn omstilling virksomheder industri'
[RAG] Found 2 chunks for Socialdemokratiet
running tool: consult_party_expert
party_expert_agent run
14:14:59.838 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.844 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.848 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.851 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.854 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.857 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.860 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.863 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.866 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.869 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:14:59.878 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:01.681 running 1 tool
14:15:01.682 running tool: get_context
[RAG] Borgernes Parti - Lars Boje Mathiesen (H): 'klima klimamål CO2 grøn omstilling'
[RAG] Found 2 chunks for Borgernes Parti - Lars Boje Mathiesen
running tool: consult_party_expert
party_expert_agent run
14:15:02.020 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:15:02.020 running 1 tool
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:15:02.020 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'klimapolitik erhverv'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:15:02.279 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'klima erhverv økonomi grøn omstilling'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:15:02.562 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:02.573 running 2 tools
running tool: consult_party_expert
party_expert_agent run
14:15:02.574 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:15:02.574 running 2 tools
running tool: consult_party_expert
party_expert_agent run
running 2 tools
14:15:02.574 running tool: get_context
[RAG] Moderaterne (M): 'klimamål CO2 reduktion'
[RAG] Found 0 chunks for Moderaterne
14:15:02.800 running tool: get_context
[RAG] Moderaterne (M): 'grøn omstilling klimapolitik'
[RAG] Found 0 chunks for Moderaterne
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:15:03.051 running tool: get_context
[RAG] Enhedslisten - De Rød-Grønne (Ø): 'klima erhverv profit virksomheder grøn omstilling'
[RAG] Found 2 chunks for Enhedslisten - De Rød-Grønne
running tool: consult_party_expert
party_expert_agent run
running 2 tools
14:15:03.352 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'klimapolitik'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:15:03.612 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'erhverv klima'
[RAG] Found 0 chunks for Det Konservative Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:15:03.881 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:03.885 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:03.895 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:03.900 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:03.903 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Alternativet done (492 chars)
<<< Party Expert → Analyst: Venstre, Danmarks Liberale Parti done (514 chars)
<<< Party Expert → Analyst: Socialdemokratiet done (489 chars)
<<< Party Expert → Analyst: Liberal Alliance done (553 chars)
<<< Party Expert → Analyst: Radikale Venstre done (491 chars)
<<< Party Expert → Analyst: Moderaterne done (110 chars)
running tool: consult_party_expert
party_expert_agent run
14:15:05.274 running 1 tool
14:15:05.275 running tool: get_context
[RAG] Borgernes Parti - Lars Boje Mathiesen (H): 'grønne afgifter klimaafgifter erhverv virksomheder'
[RAG] Found 2 chunks for Borgernes Parti - Lars Boje Mathiesen
running tool: consult_party_expert
party_expert_agent run
14:15:05.675 running 1 tool
14:15:05.675 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'klima'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
14:15:05.888 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Dansk Folkeparti done (533 chars)
running tool: consult_party_expert
party_expert_agent run
14:15:05.896 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:15:05.896 running 1 tool
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:15:05.896 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'klima før økonomi miljø vigtigere end erhverv'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:15:06.155 running tool: get_context
[RAG] Enhedslisten - De Rød-Grønne (Ø): 'erhvervsinteresser klima mennesker profit'
[RAG] Found 2 chunks for Enhedslisten - De Rød-Grønne
running tool: consult_party_expert
party_expert_agent run
14:15:06.437 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:06.447 running 2 tools
14:15:06.448 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'klima'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:15:06.692 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'CO2 reduktion'
[RAG] Found 0 chunks for Det Konservative Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:15:06.940 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:06.945 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:15:06.952 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Det Konservative Folkeparti done (110 chars)
<<< Party Expert → Analyst: SF - Socialistisk Folkeparti done (447 chars)
running tool: consult_party_expert
party_expert_agent run
14:15:30.025 running 1 tool
14:15:30.026 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'CO2 miljø grøn omstilling'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
14:15:30.340 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Borgernes Parti - Lars Boje Mathiesen done (509 chars)
<<< Party Expert → Analyst: Danmarksdemokraterne - Inger Støjberg done (110 chars)
running tool: consult_party_expert
party_expert_agent run
14:15:37.865 running 1 tool
14:15:37.867 running tool: get_context
[RAG] Enhedslisten - De Rød-Grønne (Ø): 'grøn omstilling mennesker ikke profit'
[RAG] Found 2 chunks for Enhedslisten - De Rød-Grønne
14:15:38.172 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Enhedslisten - De Rød-Grønne done (480 chars)
14:15:49.428 chat claude-sonnet-4-5
print_party_scores(result_klima_1)Party Score Reason
Ø 10 Enhedslisten er det mest radikale parti på klima. De kæmper for 'grøn omstilling - for mennesker, ikke for profit', vil have høje CO₂-afgifter der rammer de største udledere hårdest, og afviser grønne gimmicks. De vil have Danmark klimaneutral senest 2040 og fri af fossile brændsler i 2030. Klart prioriterer klima over erhvervsinteresser.
Å 9 Alternativet siger direkte, at klimaloven skal prioritere klima og fremtidige generationers rettigheder - IKKE erhvervslivets vækstpotentiale. De vil have Danmarks udledninger ned til nul mellem 2025-2035, som videnskaben kræver. Meget ambitiøs klimapolitik der klart går foran erhvervsinteresser.
F 7 SF ser den grønne omstilling som 'helt afgørende' og vil have Danmark til at gå forrest i klimakampen med ambitiøs klimapolitik. De kombinerer klima med erhverv, men fremhæver klart klimaets vigtighed og vil leve op til Parisaftalen. Stærk klimaprofil, selvom de ikke direkte siger klima over erhverv.
B 6 Radikale prioriterer klimapolitikken højt og kræver målrettet regulering og klimaafgifter på erhverv som landbruget. De ser dog også den grønne omstilling som en konkurrencefordel og erhvervsmulighed. Ambitiøs klimapolitik, men med fokus på at kombinere klima og økonomi.
A 4 Socialdemokratiet fremhæver, at grøn omstilling kan gå hånd i hånd med vækst og arbejdspladser 'uden at gå på kompromis med erhvervsinteresser'. De har nået klimamål gennem samarbejde med erhvervslivet. Moderat klimapolitik der ikke prioriterer klima over erhverv.
V 2 Venstre vil have 'ansvarlig' klimapolitik med retfærdig byrdefordeling og incitamenter frem for forbud. De ser klimaudfordringen som en erhvervsmulighed og mener omstillingen skal 'gøre Danmark rigere'. Klima og erhverv skal gå hånd i hånd - ikke klima først.
I 1 Liberal Alliance understreger, at energi er 'motoren i vores økonomi' og prioriterer stabil energi til overkommelige priser samt økonomisk vækst. De vil have markedsdrevne løsninger og nedbringe statslig kontrol. Erhvervsinteresser vejer tungt i deres klimapolitik.
C 0 Ingen relevant information om klimapolitik i Det Konservative Folkepartis partiprogram. Kan ikke vurderes på dette grundlag.
M 0 Ingen relevant information om klimapolitik i Moderaternes partiprogram. Kan ikke vurderes på dette grundlag.
Æ 0 Ingen relevant information om klimapolitik i Danmarksdemokraternes partiprogram. Kan ikke vurderes på dette grundlag.
O -2 Dansk Folkeparti prioriterer IKKE klima over erhvervsinteresser. De er imod særafgifter der forringer eksporterhvervs konkurrenceevne og mener Danmarks CO₂-udledning er 'ubetydelig'. Klimaindsatsen skal altid tage hensyn til social balance og være god for Danmark.
H -8 Borgernes Parti mener ikke, der er en klimakrise, og at klimavidenskaben er upræcis. De afviser at prioritere klima over erhvervsinteresser og vil ikke 'ruinere Danmark med grønne afgifter'. De vil fjerne transportafgifter for at give virksomheder bedre konkurrencevilkår. Klart imod din holdning.
These scores do align pretty well with how I would have assigned them. Intuitively, the “climate change concerns above economic growth” theme should resonate better with the left-wing parties than the right-wing parties.
Next, we try roughly the opposite opinion, namely that economic growth is the top priority. And as one would hope, the parties are now ranked in roughly the opposite direction.
result_klima_2 = await political_analyst_agent.run(
"Økonomisk vækst er førsteprioritet for mig. Lad mig se en score for alle partierne"
)14:17:49.636 political_analyst_agent run
14:17:49.639 chat claude-sonnet-4-5
14:17:57.530 running 12 tools
14:17:57.531 running tool: consult_party_expert
>>> Analyst → Party Expert: Socialdemokratiet (A), query='økonomisk vækst'
14:17:57.532 party_expert_agent run
14:17:57.533 running tool: consult_party_expert
>>> Analyst → Party Expert: Radikale Venstre (B), query='økonomisk vækst'
14:17:57.534 party_expert_agent run
14:17:57.534 running tool: consult_party_expert
>>> Analyst → Party Expert: Det Konservative Folkeparti (C), query='økonomisk vækst'
14:17:57.548 party_expert_agent run
14:17:57.548 running tool: consult_party_expert
>>> Analyst → Party Expert: SF - Socialistisk Folkeparti (F), query='økonomisk vækst'
14:17:57.549 party_expert_agent run
14:17:57.549 running tool: consult_party_expert
>>> Analyst → Party Expert: Borgernes Parti - Lars Boje Mathiesen (H), query='økonomisk vækst'
14:17:57.549 party_expert_agent run
14:17:57.549 running tool: consult_party_expert
>>> Analyst → Party Expert: Liberal Alliance (I), query='økonomisk vækst'
14:17:57.550 party_expert_agent run
14:17:57.550 running tool: consult_party_expert
>>> Analyst → Party Expert: Dansk Folkeparti (O), query='økonomisk vækst'
14:17:57.550 party_expert_agent run
14:17:57.551 running tool: consult_party_expert
>>> Analyst → Party Expert: Moderaterne (M), query='økonomisk vækst'
14:17:57.551 party_expert_agent run
14:17:57.551 running tool: consult_party_expert
>>> Analyst → Party Expert: Venstre, Danmarks Liberale Parti (V), query='økonomisk vækst'
14:17:57.552 party_expert_agent run
14:17:57.552 running tool: consult_party_expert
>>> Analyst → Party Expert: Danmarksdemokraterne - Inger Støjberg (Æ), query='økonomisk vækst'
14:17:57.552 party_expert_agent run
14:17:57.552 running tool: consult_party_expert
>>> Analyst → Party Expert: Enhedslisten - De Rød-Grønne (Ø), query='økonomisk vækst'
14:17:57.553 party_expert_agent run
14:17:57.553 running tool: consult_party_expert
>>> Analyst → Party Expert: Alternativet (Å), query='økonomisk vækst'
14:17:57.554 party_expert_agent run
running tool: consult_party_expert
party_expert_agent run
14:17:57.555 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.557 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.558 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.559 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.560 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.561 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.562 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.563 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.564 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.564 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.565 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:57.566 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:17:59.166 running 1 tool
14:17:59.167 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'økonomisk vækst'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
14:17:59.487 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:17:59.487 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:17:59.487 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:17:59.487 running 1 tool
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:17:59.487 running tool: get_context
[RAG] Alternativet (Å): 'økonomisk vækst'
[RAG] Found 2 chunks for Alternativet
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:17:59.733 running tool: get_context
[RAG] Liberal Alliance (I): 'økonomisk vækst'
[RAG] Found 2 chunks for Liberal Alliance
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:00.070 running tool: get_context
[RAG] Dansk Folkeparti (O): 'økonomisk vækst'
[RAG] Found 2 chunks for Dansk Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:00.325 running tool: get_context
[RAG] Socialdemokratiet (A): 'økonomisk vækst'
[RAG] Found 2 chunks for Socialdemokratiet
running tool: consult_party_expert
party_expert_agent run
14:18:00.571 running 1 tool
14:18:00.574 running tool: get_context
[RAG] Radikale Venstre (B): 'økonomisk vækst'
[RAG] Found 2 chunks for Radikale Venstre
running tool: consult_party_expert
party_expert_agent run
14:18:00.825 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:00.825 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:00.825 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:00.826 running 1 tool
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:00.826 running tool: get_context
[RAG] Enhedslisten - De Rød-Grønne (Ø): 'økonomisk vækst'
[RAG] Found 2 chunks for Enhedslisten - De Rød-Grønne
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:01.055 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'økonomisk vækst'
[RAG] Found 0 chunks for Det Konservative Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:01.298 running tool: get_context
[RAG] Venstre, Danmarks Liberale Parti (V): 'økonomisk vækst'
[RAG] Found 2 chunks for Venstre, Danmarks Liberale Parti
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:01.530 running tool: get_context
[RAG] Borgernes Parti - Lars Boje Mathiesen (H): 'økonomisk vækst'
[RAG] Found 2 chunks for Borgernes Parti - Lars Boje Mathiesen
running tool: consult_party_expert
party_expert_agent run
14:18:01.770 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:01.771 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:01.771 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:01.774 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'økonomisk vækst'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:02.024 running tool: get_context
[RAG] Moderaterne (M): 'økonomisk vækst'
[RAG] Found 0 chunks for Moderaterne
running tool: consult_party_expert
party_expert_agent run
14:18:02.268 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.270 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.272 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.274 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.282 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.286 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.288 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.289 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.291 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.293 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:02.294 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:03.899 running 1 tool
14:18:03.900 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'vækst økonomi'
[RAG] Found 0 chunks for Det Konservative Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:18:04.173 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:04.173 running 1 tool
running tool: consult_party_expert
party_expert_agent run
14:18:04.173 running 1 tool
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:04.173 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'vækst økonomi'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:04.402 running tool: get_context
[RAG] Liberal Alliance (I): 'vækst produktivitet erhvervsudvikling'
[RAG] Found 2 chunks for Liberal Alliance
running tool: consult_party_expert
party_expert_agent run
running 1 tool
14:18:04.661 running tool: get_context
[RAG] Moderaterne (M): 'vækst økonomi'
[RAG] Found 0 chunks for Moderaterne
running tool: consult_party_expert
party_expert_agent run
14:18:04.915 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:04.922 running 1 tool
14:18:04.922 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'vækst BNP økonomi'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:18:05.160 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:05.163 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:05.167 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Dansk Folkeparti done (369 chars)
running tool: consult_party_expert
party_expert_agent run
14:18:05.174 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Alternativet done (426 chars)
<<< Party Expert → Analyst: Socialdemokratiet done (376 chars)
<<< Party Expert → Analyst: Venstre, Danmarks Liberale Parti done (427 chars)
<<< Party Expert → Analyst: Borgernes Parti - Lars Boje Mathiesen done (538 chars)
<<< Party Expert → Analyst: Enhedslisten - De Rød-Grønne done (431 chars)
<<< Party Expert → Analyst: Radikale Venstre done (501 chars)
running tool: consult_party_expert
party_expert_agent run
14:18:22.410 running 1 tool
14:18:22.411 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'erhverv virksomheder konkurrenceevne'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
14:18:22.744 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:22.835 running 1 tool
14:18:22.835 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'vækst erhverv'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:18:23.074 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:23.484 running 1 tool
14:18:23.485 running tool: get_context
[RAG] Liberal Alliance (I): 'erhvervsliv virksomheder konkurrenceevne'
[RAG] Found 2 chunks for Liberal Alliance
14:18:23.739 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:30.418 running 1 tool
14:18:30.419 running tool: get_context
[RAG] Moderaterne (M): 'BNP produktivitet vækst'
[RAG] Found 0 chunks for Moderaterne
14:18:30.726 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:30.824 running 1 tool
14:18:30.824 running tool: get_context
[RAG] Danmarksdemokraterne - Inger Støjberg (Æ): 'økonomi BNP produktion'
[RAG] Found 0 chunks for Danmarksdemokraterne - Inger Støjberg
running tool: consult_party_expert
party_expert_agent run
14:18:31.077 running 1 tool
14:18:31.078 running tool: get_context
[RAG] SF - Socialistisk Folkeparti (F): 'grøn vækst bæredygtig økonomi'
[RAG] Found 2 chunks for SF - Socialistisk Folkeparti
running tool: consult_party_expert
party_expert_agent run
14:18:31.333 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:31.339 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Danmarksdemokraterne - Inger Støjberg done (64 chars)
<<< Party Expert → Analyst: SF - Socialistisk Folkeparti done (468 chars)
running tool: consult_party_expert
party_expert_agent run
14:18:46.268 running 1 tool
14:18:46.268 running tool: get_context
[RAG] Det Konservative Folkeparti (C): 'BNP produktivitet'
[RAG] Found 0 chunks for Det Konservative Folkeparti
14:18:46.578 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:49.114 running 1 tool
14:18:49.114 running tool: get_context
[RAG] Liberal Alliance (I): 'skattelettelser arbejde beskæftigelse'
[RAG] Found 2 chunks for Liberal Alliance
running tool: consult_party_expert
party_expert_agent run
14:18:49.451 running 1 tool
14:18:49.452 running tool: get_context
[RAG] Moderaterne (M): 'velstand økonomi'
[RAG] Found 0 chunks for Moderaterne
running tool: consult_party_expert
party_expert_agent run
14:18:49.658 chat claude-sonnet-4-5
running tool: consult_party_expert
party_expert_agent run
14:18:49.667 chat claude-sonnet-4-5
14:18:56.975 running 1 tool
14:18:56.975 running tool: get_context
[RAG] Moderaterne (M): 'erhverv virksomheder konkurrenceevne'
[RAG] Found 0 chunks for Moderaterne
14:18:57.294 chat claude-sonnet-4-5
<<< Party Expert → Analyst: Liberal Alliance done (440 chars)
<<< Party Expert → Analyst: Det Konservative Folkeparti done (64 chars)
<<< Party Expert → Analyst: Moderaterne done (64 chars)
14:19:06.139 chat claude-sonnet-4-5
print_party_scores(result_klima_2)Party Score Reason
I 9 Liberal Alliance har den mest eksplicitte vækstdagsorden med fokus på skattelettelser, bedre vilkår for virksomheder og investeringer. De argumenterer direkte for, at lavere skatter vil øge beskæftigelse og innovation, hvilket er kernen i klassisk vækstpolitik.
V 9 Venstre sætter vækst og velstand som forudsætning for velfærd. De har konkret løftet arbejdsudbuddet med 30.000+ gennem reformer og prioriterer en sund privat sektor med virkelyst. Klar vækstorienteret tilgang.
H 8 Borgernes Parti ser økonomisk vækst som direkte resultat af et stærkt erhvervsliv. De vil fremme vækst gennem lavere skatter, mindre bureaukrati og bedre iværksættervilkår - en klassisk liberal vækststrategi.
C 7 Konservative har ingen specifik information om vækst i deres program, men partiet er traditionelt erhvervsvenligt og vækstorienteret. Score baseret på partiets generelle profil.
M 6 Moderaterne har ingen specifik information om vækst i deres program. Som centerparti forventes en balanceret tilgang mellem vækst og andre hensyn.
B 5 Radikale ser stærk økonomi som fundament, men primært som middel til at finansiere grøn omstilling og velfærd. Vækst er ikke førsteprioritet i sig selv, men et redskab til andre mål.
A 4 Socialdemokratiet fremhæver Danmarks stærke økonomi, men fokuserer mere på lighed og retfærdighed end på vækst. Økonomisk politik skal være 'til gavn for alle - ikke kun de få', hvilket indikerer omfordelingsfokus over vækstfokus.
F 3 SF prioriterer langsigtet og bæredygtig udvikling over kortsigtet vækst. Grøn omstilling er vækstmotoren, men traditionel økonomisk vækst er ikke førsteprioritet - det er bæredygtighed og langsigtede investeringer.
Æ 2 Danmarksdemokraterne har ingen information om økonomisk vækst i deres program. Partiet fokuserer primært på udlændingepolitik og nationale værdier.
O 1 Dansk Folkeparti nævner kun økonomisk vækst i kontekst af udviklingslande og udviklingsbistand. Ingen indenrigspolitisk vækststrategi præsenteret - partiet fokuserer primært på udlændingepolitik.
Ø -5 Enhedslisten vil aktivt ændre kurs væk fra traditionel vækst til grøn omstilling. De afviser 'evigt merforbrug' som vej til velstand og prioriterer cirkulær økonomi over vækst. Direkte modsat en vækstdagsorden.
Å -7 Alternativet afviser eksplicit vækstspiralen og mener, vi ikke kan fortsætte med vækstfokus. De vil ændre bundlinjer væk fra vækst til klima, miljø og sociale faktorer. Mest kritiske overfor traditionel økonomisk vækst.
During the implementation of this demo, I stumbled on a few technical issues that I had to sort out. I just added them here for clarity.
Some party web sites are very defensive when it comes to allowing automated requests (looking at you, Socialdemokratiet). So, simply calling requests.get() did not work. In order to even read the html of some party web sites, both cookies and javascript was needed. Playwright with the Chromium rendering engine came to the rescue.
With multiple agents complexity can grow rapidly and figuring out exactly where things go wrong can be tedious. Logfire is a powerful tool for debugging multi-agent implementations. In the screenshot below we see a party expert agent formulating a party’s stance on “economic growth” based on the relevant chunks from the party manifest.
Multi-agent setups can be more demanding for the LLM models and as everything in this demo runs locally, it was a challenge to find a model capable of dealing with the orchestration of the party experts and still being small enough to run on my 16 GB laptop. In the end the qwen3:8B model was found to perform reasonably ok while also not crashing my laptop. However evaluation is slow at around 15+ minutes per query and the model really struggled. The model often had problems generating JSON in the required formats and it often also forgot some of the parties in the evaluation.
Switching to Anthropic’s API to use Sonnet 4.5 solved these issues. Evaluation times are less than 2 minutes, JSON is on point, all parties are included and results seem intuitively sane.
In this project I just fetched the main page on policy (including subpages) for each party and the amount text available varies quite a bit between parties. That can be seen above where the political analyst agent states that there is no information on climate policy for three parties and that it therefore can not score them. Many other sources could be included to improve the answers but for this demo’s purpose I just kept it simple.
Agentic delegation allows AI agents to tackle large and complex tasks by planning and dividing work into relevant subtasks. There are many plausible commercial use cases for agent delegation. Given the nature of the underlying LLMs these agents especially shine in cases with large amounts of unstructured text. Customer support and experience is one such case including ticket triage, proactive customer outreach and automatic review analysis. Many other use cases exist within marketing, accounting, HR and supply chain automation.
Please reach out on LinkedIn if I can help with multi-agent deployment or other ML/AI endeavors.