3
0

Anpassungen REQUIRE_FULL_SOLVE

This commit is contained in:
Magnus Bender 2024-12-21 19:41:23 +01:00
parent 789b2db221
commit c0aafe41b4
Signed by: bender
GPG Key ID: 5149A211831F2BD7
4 changed files with 13 additions and 4 deletions

View File

@ -49,7 +49,7 @@ Der Beispielagent kann Rechenaufgaben lösen, dabei ist das Rätsel eine einfach
"question": "x * y =",
"solutions_before": []
},
"solution": null,
"solution": [],
"data": [
{
"type": "text",

View File

@ -43,6 +43,10 @@ Die Zusammenführung findet nur innerhalb von Rätseln mit der gleichen ID statt
Falls `REQUIRE_FULL_EXTRACT=true` so muss sichergestellt werden, dass auch alle Agenten (also für jeden Datensatz) irgendwann eine Extraktion bestimmt wird, andernfalls wartet das Management ewig.
Bei `REQUIRE_FULL_EXTRACT=false` bekommt der Agent zum Lösen ein Rätsel dann evtl. doppelt, jeweils mit weiteren Extraktionen.
Mit `REQUIRE_FULL_SOLVE` kann (ähnlich zu `REQUIRE_FULL_EXTRACT`) das Management angewiesen werden, von allen Agenten (in `AGENTS_SOLVE`) eine Lösung abzuwarten, bevor diese Lösungen (gebündelt) an den Gatekeeper zum Prüfen weitergeleitet werden.
Auch hier muss bei `REQUIRE_FULL_SOLVE=true` sichergestellt werden, dass alle Agenten auch (in `AGENTS_SOLVE`) irgendwann eine Lösung ausgeben.
Außerdem darf die Lösung von zwei Agenten nicht komplett identisch sein, d.h., wenn Lösung, Erklärung und benutzte Dateien einer Lösung gleich sind, so wird sie als die selbe Lösung angesehen und das Management würde z.B. auf eine *weitere* Lösung warten.
Ein Agent kann eine Antwort aber auch nicht nur stoppen, sondern auch für später aufheben (via <http://localhost:8080/docs/ums/agent/agent.html#BasicAgent.before_response>).
So kann ein Agent z.B. auf die Lösung einer Unteraufgabe warten und erst anschließend seine Antwort an das Management senden.

View File

@ -17,7 +17,9 @@ services:
# limit to prevent messages in never ending cycles
- MESSAGE_MAX_CONTACTS=100
# wait for all extraction agents to return results before solving a riddle
- REQUIRE_FULL_EXTRACT=false
- REQUIRE_FULL_EXTRACT=true
# wait for all solve agents to return a solutions before giving to gatekeeper
- REQUIRE_FULL_SOLVE=true
# how to access management (the host name is the name of the service in this file)
- MANAGEMENT_URL=http://management
# *register* the agents to the management

View File

@ -9,7 +9,7 @@
# https://www.gnu.org/licenses/gpl-3.0.txt
import re
from typing import Callable
from typing import Callable, List
from ums.agent import GatekeeperAgent
from ums.utils import Riddle, RiddleSolution, AgentMessage
@ -21,9 +21,12 @@ class SimpleSolveAgent(GatekeeperAgent):
# do not send a response, if this is not a calculator riddle!
return not self.stop_response
def handle(self, solution: RiddleSolution, riddle: Riddle) -> RiddleSolution:
def handle(self, solution: List[RiddleSolution], riddle: Riddle) -> List[RiddleSolution]:
self.stop_response = False
# iterate over all poss. solutions
return [self._check_single_solution(s) for s in solution]
def _check_single_solution(self, solution:RiddleSolution) -> RiddleSolution:
# first check for errors
if solution.solution == "Error":
solution.accepted = True