Recent

Author Topic: AI: Agentic Design Patterns  (Read 1161 times)

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
AI: Agentic Design Patterns
« on: October 22, 2025, 05:52:20 pm »
22 essential agentic design patterns for building intelligent AI systems:

https://zeljkoavramovic.github.io/agentic-design-patterns
https://github.com/zeljkoavramovic/agentic-design-patterns

If you like it then please spread the word and give it a star  :D
« Last Edit: October 24, 2025, 02:57:22 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 18304
  • Here stood a man who saw the Elbe and jumped it.
Re: AI: Agentic Design Patterns
« Reply #1 on: October 22, 2025, 06:44:54 pm »
I like it a lot, but I am missing the awareness pattern. (Taken from Brahms, multi-user agent language - NASA Ames rover)
There an agent will look if it can perform a task but evaluates if there is an agent better suited.
(spatial awareness)

It works like this:
- assume an agent can sort (bubble)
- but it knows there are agents that are better (qsort)
- it knows a better agent is available and diverts otherwise it bubbles away

Other example (from the mars rover)
- agent a is closer to earth
- agent b is closer to mars
- both can perform the same task
Agent a gives the task to agent b if synchronization to exchange data is time-critical.
Data exchange is given back to a when b has the data.

https://www.researchgate.net/publication/238675575_Brahms_A_multi-agent_modelling_environment_for_simulating_work_processes_and_practices

The author is now the head of automotive AI at Honda, formerly NASA Ames

This pattern is related to scattering patterns.

A Pascal implementation could be done with distributed priority queues as a basis.
« Last Edit: October 22, 2025, 07:13:47 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: AI: Agentic Design Patterns
« Reply #2 on: October 22, 2025, 07:56:38 pm »
I like it a lot, but I am missing the awareness pattern.
Thanks Thaddy, I am glad you like it. ;)

Awareness could be replaced by using 3 core patterns - Reflection, Inter-Agent Communication and Routing:

Quote
1. [Reflection]
   Agent A evaluates:
   - "My sort: BubbleSort -> O(n²)"
   - "Estimated cost: 10s"

2. [Inter-Agent Communication]
   Agent A queries network:
   - "Who can sort <array_size> in < 2s?"
   - Agent B responds: "I have QuickSort -> O(n log n), 1.2s"

3. [Routing]
   Agent A decides:
   - "Agent B is better -> delegate"
   - Routes task + data to Agent B

Potential Enhancements:
  • Memory Management (cache known agent capabilities, faster future decisions)
  • Resource-Aware Optimization (factor in latency, energy, or load - like rover proximity to Mars)
  • Multi-Agent Collaboration (define roles, track capabilities)
  • Evaluation & Monitoring (log delegation success to improve future routing)

Awareness is a composition, not a primitive. Therefore I would prefer to tag it as a meta-pattern or a system pattern. Including it would indeed simplify usage of a non-obvious composition pattern, as several other composition patterns already do.
« Last Edit: October 22, 2025, 08:18:13 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

gidesa

  • Full Member
  • ***
  • Posts: 196
Re: AI: Agentic Design Patterns
« Reply #3 on: October 22, 2025, 08:22:11 pm »
21 essential agentic design patterns for building intelligent AI systems:

https://zeljkoavramovic.github.io/agentic-design-patterns
https://github.com/zeljkoavramovic/agentic-design-patterns

If you like it then please spread the word and give it a star  :D

Very interesting work, thanks! Just starred on github :-)
Are there some Fpc/Delphi library to create AI agents?

Thaddy

  • Hero Member
  • *****
  • Posts: 18304
  • Here stood a man who saw the Elbe and jumped it.
Re: AI: Agentic Design Patterns
« Reply #4 on: October 22, 2025, 08:34:27 pm »
@Avra
No you can't replace it.
The correct awareness pattern is inhibiting. Looks to the outside from within. There is a logic clash otherwise.
Consider humans and dna.
What Maarten Sierhuis proposed in his thesis, and generally accepted, is that agents are born with a certain set of capabilities.
Dna - he did not use that term -. and perform those capabilities anyway, without contact.(example: a timer is such an agent, or a temperature probe.)
It is a thin line, I know, but quite essential.
Awareness exposure depends on being asked to present its internal knowledge and asked for an opinion otherwise.
It is not imperative in that sense. Agents are working entities, not oracles. They report state.
« Last Edit: October 23, 2025, 09:27:24 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: AI: Agentic Design Patterns
« Reply #5 on: October 24, 2025, 05:26:27 am »
@Thaddy: Your remarks are valid. Please review attached Awareness agentic design pattern.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 18304
  • Here stood a man who saw the Elbe and jumped it.
Re: AI: Agentic Design Patterns
« Reply #7 on: October 24, 2025, 06:08:57 am »
@Avra
That is correct, I will show it to Maarten and ask for review.
As far as I can tell you are spot on.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: AI: Agentic Design Patterns
« Reply #8 on: October 24, 2025, 02:15:12 pm »
Good to know. Thanks Thaddy!  ;)

REPO NEWS: Added Awareness pattern. Pattern Relationships diagram is now clickable. Updated Use Cases, README.md and Credits.

Links are in the first message.
« Last Edit: October 24, 2025, 03:03:27 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 18304
  • Here stood a man who saw the Elbe and jumped it.
Re: AI: Agentic Design Patterns
« Reply #9 on: October 28, 2025, 02:57:22 pm »
Btw: if you want write your own fuzzer, experiment with this: (0.123 kb  O:-) )
https://forum.lazarus.freepascal.org/index.php/topic,42900.msg299916.html#msg299916

My version just presents a way to express Zadeh's fuzzy logic systems with well known logical operators.

NOT an engine, but for those that write engines 
« Last Edit: October 28, 2025, 03:04:54 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: AI: Agentic Design Patterns
« Reply #10 on: October 29, 2025, 10:07:17 am »
Btw: if you want write your own fuzzer, experiment with this
You mixed threads  :D. I mentioned Fuzzy Logic in this thread:
https://forum.lazarus.freepascal.org/index.php/topic,72218.msg568592.html#msg568592

I already use operators in a similar, but not the exact way. Anyway, this is one fuzzy logic example:
Code: Pascal  [Select][+][-]
  1. program SmartAirConditioner;
  2.  
  3. // This program demonstrates a fuzzy logic based smart air conditioning system that adjusts fan speed based on temperature and humidity inputs.
  4. // It defines three linguistic variables (Temperature, Humidity, and FanSpeed) with corresponding fuzzy sets, using a mix of linear and
  5. // triangular membership functions to model different environmental conditions and fan speeds. The system employs a Mamdani type
  6. // Fuzzy Inference System (FIS) with nine rules that encode expert knowledge about comfort levels and appropriate fan speeds for various
  7. // temperature and humidity combinations. The example evaluates the system for a specific scenario (30°C temperature and 70% humidity),
  8. // using the LoM method for defuzzification to determine the recommended fan speed. This simplified model illustrates how fuzzy logic
  9. // can be applied to create a more nuanced and adaptive air conditioning control system, potentially offering improved comfort and
  10. // energy efficiency compared to traditional thermostat systems.
  11.  
  12. {$i fuzzyrulehelper.inc}
  13.  
  14. uses
  15.   SysUtils, FuzzyLogic;
  16.  
  17. var
  18.   Temperature, Humidity, FanSpeed: TFuzzyVar;
  19.   TempCold, TempPleasant, TempWarm, HumDry, HumNormal, HumWet, FanLow, FanMedium, FanHigh: TFuzzySet;
  20.   FIS: TFuzzySystemMamdani;
  21.   InputTemp, InputHum, OutputFanSpeed: TFuzzyNumeric;
  22.  
  23. begin
  24.   // Define linguistic variables and fuzzy sets
  25.   Temperature  := TFuzzyVar.Create('Temperature', '°C', 0,  50);
  26.   TempCold     := TFuzzySet.Create(Temperature, 'Cold',     fmLinearFalling, [10,  20]);
  27.   TempPleasant := TFuzzySet.Create(Temperature, 'Pleasant', fmTriangular,    [15,  25,  35]);
  28.   TempWarm     := TFuzzySet.Create(Temperature, 'Warm',     fmLinearRising,  [30,  40]);
  29.  
  30.   Humidity     := TFuzzyVar.Create('Humidity',    '%',  0, 100);
  31.   HumDry       := TFuzzySet.Create(Humidity,    'Dry',      fmTriangular,    [ 0,  25,  50]);
  32.   HumNormal    := TFuzzySet.Create(Humidity,    'Normal',   fmTriangular,    [25,  50,  75]);
  33.   HumWet       := TFuzzySet.Create(Humidity,    'Wet',      fmTriangular,    [50,  75, 100]);
  34.  
  35.   FanSpeed     := TFuzzyVar.Create('FanSpeed',    '%',  0, 100, fvOutput);
  36.   FanLow       := TFuzzySet.Create(FanSpeed,    'Low',      fmLinearFalling, [ 0,  50]);
  37.   FanMedium    := TFuzzySet.Create(FanSpeed,    'Medium',   fmTriangular,    [25,  50,  75]);
  38.   FanHigh      := TFuzzySet.Create(FanSpeed,    'High',     fmLinearRising,  [50, 100]);
  39.  
  40.   // Create Fuzzy Inference System
  41.   FIS := TFuzzySystemMamdani.Create;
  42.  
  43.   // Define rules
  44.   FIS.AddRule(_IF_ TempCold _AND_ HumDry _THEN_ FanLow); // IF TempCold     AND HumDry    THEN FanLow
  45.   //FIS.AddRule([TempCold,     HumDry],    FanLow);      // IF TempCold     AND HumDry    THEN FanLow
  46.   FIS.AddRule([TempCold,     HumNormal], FanLow);        // IF TempCold     AND HumNormal THEN FanLow
  47.   FIS.AddRule([TempCold,     HumWet],    FanMedium);     // IF TempCold     AND HumWet    THEN FanMedium
  48.   FIS.AddRule([TempPleasant, HumDry],    FanLow);        // IF TempPleasant AND HumDry    THEN FanLow
  49.   FIS.AddRule([TempPleasant, HumNormal], FanLow);        // IF TempPleasant AND HumNormal THEN FanLow
  50.   FIS.AddRule([TempPleasant, HumWet],    FanMedium);     // IF TempPleasant AND HumWet    THEN FanMedium
  51.   FIS.AddRule([TempWarm,     HumDry],    FanMedium);     // IF TempWarm     AND HumDry    THEN FanMedium
  52.   FIS.AddRule([TempWarm,     HumNormal], FanMedium);     // IF TempWarm     AND HumNormal THEN FanMedium
  53.   FIS.AddRule([TempWarm,     HumWet],    FanHigh);       // IF TempWarm     AND HumWet    THEN FanHigh
  54.  
  55.   // Example evaluation
  56.   InputTemp      := 30;
  57.   InputHum       := 70;
  58.   OutputFanSpeed := FIS.Evaluate([InputTemp, InputHum], fdmLoM); // Largest-Of-Maximum Mamdani defuzzification
  59.  
  60.   WriteLn(Format('Temperature: %.1f°C, Humidity: %.1f%%', [InputTemp, InputHum]));
  61.   WriteLn(Format('Recommended Fan Speed: %.1f%%', [OutputFanSpeed]));
  62.   ReadLn;
  63.  
  64.   // Clean up
  65.   FIS.Free;
  66. end.
  67.  

Look at how first rule is defined  ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018