Extend AI Logging Capabilities
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3493277. -->
Reported by: [seogow](https://www.drupal.org/user/3065779)
Related to !507 !504 !471
>>>
<p>--- AI TRACKER METADATA ---<br>
<strong>Update Summary: </strong>AI Logging<br>
<strong>Check-in Date: </strong>09/03/2025 (US format) [When we should see progress/get an update]<br>
<strong>Due Date:</strong> MM/DD/YYYY (US format) [When the issue should be fully completed]<br>
<strong>Blocked by:</strong> [#XXXXXX] (New issues on new lines)<br>
<strong>Additional Collaborators:</strong> @username1, @username2<br>
AI Tracker found here: <a href="https://www.drupalstarforge.ai/" title="AI Tracker">https://www.drupalstarforge.ai/</a><br>
--- END METADATA ---</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Enhance the AI Logging module to provide more granular logging capabilities, better filtering, and integration with the new process system.</p>
<p>Current logging system needs enhancement to:</p>
<ul>
<li>Distinguish between LLM and Agent operations</li>
<li>Provide different logging levels</li>
<li>Support process chain tracking</li>
<li>Better integrate with monitoring</li>
<li> Maybe the non-raw output would be good on the summary page</li>
</ul>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ol>
<li>Enhanced Log Types
<ul>
<li>LLM operations logging</li>
<li>Agent operations logging</li>
</ul>
</li>
<li>Logging Levels for LLM operations
<ul>
<li>Error level</li>
<li>Info level</li>
</ul>
</li>
<li>UI Improvements
<ul>
<li>Enhanced log viewer</li>
<li>Better filtering interface</li>
</ul>
</li>
</ol>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>Introduce tabbed design:</p>
<ol>
<li><strong>AI generated summary of this call</strong>:
<ul>
<li><strong>User query</strong>: Summary of query sent to LLM</li>
<li><strong>Response of this call</strong>: Summary of LLM response</li>
<li><strong>Response of the last child call (if a child exists)</strong>: Summary of last child LLM response</li>
</ul>
</li>
<li><strong>Prompt sent to LLM</strong>:
<ul>
<li><strong>Label (Enum)</strong>: Can be repeated independently | Cannot be repeated independently [function call]</li>
<li><strong>Prompt</strong>: Prompt formatted as a chat, i.e. assistant messages indented and with darker background.</li>
</ul>
</li>
<li><strong>Actions which were available (is any)</strong>: Table of functions available/known to LLM.</li>
<li><strong>Actions which were called (if any)</strong>: Table (single row) of function called.</li>
<li><strong>Child calls chain (if any)</strong>: Table of AI generated summaries of the sub-calls.</li>
<li><strong>Tags</strong>: Unordered list of LLM call tags assigned by AI Logger.</li>
<li><strong>Prompt metadata</strong>:
<ul>
<li>Operation Category (Enum): Agent (called function) | LLM (returned response)</li>
<li>Severity Level (Enum): Info | Error</li>
<li>Operation Type (enum): chat | code | (possibly more in future)</li>
<li>Provider: LLM Provider name.</li>
<li>Model: LLM Model name</li>
<li>Started on: Date on which the call was made.</li>
<li>Started microtime: Microtome when the call started.</li>
<li>Finished microtime: Microtome when the call finished.</li>
<li>Duration (ms): Call duration in milliseconds.</li>
</ul>
</li>
<li><strong>Raw response</strong>: JSON Raw response from LLM API.</li>
</ol>
<h3 id="summary-api-changes">API changes</h3>
<ul>
<li>Expose integration API</li>
</ul>
<h3 id="summary-data-model-changes">Data model changes</h3>
<ul>
<li>New log type</li>
</ul>
> Related issue: [Issue #3493260](https://www.drupal.org/node/3493260)
> Related issue: [Issue #3493240](https://www.drupal.org/node/3493240)
issue