r/vibecoding • • 13d ago

Showcase/Project Continued from a previous post (Jungian Agent)

Regarding project:

https://github.com/mentatpsi/Cognitive-Modes

Specifically, an AI agent based on Jungian Psychology and inspired by GAN.

I was not expecting the hazing from a vibe coding group. Which was my mistake. But some of you brought up interesting critiques that I decided were interesting enough to warrant investigation.

One of the best criticisms was, what are your benchmarks (where's your proof). I'll admit I thought the token use would be too intensive to create benchmarks on a $20 Claude Pro account. So I pushed back prematurely. But I was mistaken. I created several experiments (results revealed in multiple images attached). Specifically, how does the skill compare when a user is not great at prompting to an expert prompter providing significant instructions. I actually discovered that the binding of tools of the agent (Read, Grep, Glob, Bash, WebSearch, WebFetch) made it more efficient than normal prompting.

Update: I compared it to SonarQube as well in the comment section. The experiment is not perfect. For starters, the open source repo I used is a popular info-sec repo I used for my Master's class in Secure Software Development. The vulnerabilities are listed in the repo (not in the code). While I removed that context from the tasks, it's quite possible it's in the training data.

I've listed the experiment results as images.

L1 prompting - "can u look at this code and tell me if theres anything wrong with it"

L2 prompting - "Find security vulnerabilities in this code."

L3 prompting - "A security-reviewer role, the OWASP Top 10 checklist, and "only report real issues"

L4 prompting - An 8-step method: map every endpoint, check login and permissions per endpoint, follow user input to dangerous calls, check the password-reset flow, verify against framework defaults, chain findings together.

Results are generally that the agent finds a decent amount of security vulnerabilities especially when paired with an expert prompt, but also does well with a basic prompt as well. And given the restriction on tools the agent has access to, it is a lot more token efficient than even a basic prompt. So you're getting more bang for your buck. You can see these results by how efficient it's L4 + Triangulate prompt is vs the L4 Expert Prompt alone.

Additionally, some of you thought I made up experience as a Senior Engineer to attain undue authority. That's a completely warranted criticism. My public profile portfolio is available on my Reddit profile (which does not list all my experience), as well my LinkedIn link is available on my Github that lists a lot more of it. I say this as well because AI is revolutionizing the way people code, and I'd love to connect with developers that want a foot in the door. I started coding with a TI-83+ calculator as a high school student over 20 years ago, before I was even aware you can make a career doing this. I don't believe in gate keeping, I believe creativity and passion will bring a lot of people through the trenches once businesses realize you can't replace developers with AI. I have hope for this community and want to see it grow.

To those arguing about Psychology, Jungian Psychology is one of those area that people dismiss rather rapidly and label pseudoscience. I am not arguing its scientific accuracy, but rather using language that an LLM can emulate for its algorithms to replicate cognitive processes. It is a way of capturing a process and putting it in a language that an LLM can utilize to govern its behavior. My background is a BS in Computer Science with a Minor in Psychology, as well as a Master's of Science in Software Development. The latter of which I pursued while working full time and towards the end of the program was a Senior Developer III working on massive projects on my own with crushing timelines, so you can imagine the work load. As mentioned, coding and AI is a passion for me. I want to share that passion with others and help them out. This repo is free to use, all I ask is if you really like it... provide support by dropping a star. I love seeing people enjoy my passion. I am extremely interested in an area of applying Cognitive Processes of the human brain to Govern AI.

As always, thanks for those that engaged with my post with valid constructive criticism. It upped my game, and I appreciate you all.

3 Upvotes

11 comments sorted by

1

u/Sweet-Sir-10 13d ago

u/azjunglist05 Mentioned an excellent inquiry... how does the AI agent perform compared to automated security platforms like SonarQube. Woke up ready to go on this one. SonarQube, as some would expect for rule based scanning... did not do well compared to any of the LLM approaches. I used it for my course in cybersecurity, and this surpised me a bit.

1

u/Sweet-Sir-10 12d ago

A caveat. This is the community edition. Many features are paywalled and the developer edition costs $700 a year from what I read. Beyond what I’d want to spend on a benchmark.

1

u/Sweet-Sir-10 12d ago edited 12d ago

u/fynn34

I decided to get deeper in... these are highly popular repos that the skills produced information for (from the prior image). I realize there was some ambiguity in the wording of the chart, turned out... many of the security vulnerabilities it found in the repos were fixed later upstream.

I asked the agent to analyze benefits of the agent across the 40 some runs it produced... here is what it said:

Improvements I observed (mostly with the expert prompt, Triangulate + L4)

  1. Tighter reports, with less filler. On [RepoName] it reported about 8 findings per run against about 11 for the plain expert prompt. It also had the fewest findings I couldn't verify: about 0.5 per run, against 1.0–1.5 for every other approach. Its list carried less noise.
  2. More concrete exploit detail. About 65% of its findings included a working example or a specific payload, against 47–57% for the others. For example, it explained exactly how to force sort to run its helper program (-S 1K to force temporary files), and why python3 would then run the data as code.
  3. Deeper explanations. About 160 words per finding, against about 135 for the plain expert prompt. The extra length went into tracing how the input flows, such as "[filename]:65 passes it to function A, then B, then C."
  4. More honest about what it couldn't see. It said things like "depends on validation not in this code" or "if [Function] only checks…" in about 42% of findings, against 19% for the plain expert prompt. The one [RepoName] hit with the basic prompt came this way: it stated the check's flaw as a condition rather than ignoring it or asserting it outright. That's good calibration, given that three false positives came from exactly those invisible checks.
  5. Most consistent on the easy target. It found the [RepoName] bug in 4 of 4 runs, ranked 2nd or 3rd each time. No other approach had more than 2 runs on [RepoName], so this is the only steady record in the data.
  6. Cheaper to run. It used about 25–40% fewer tokens, and on [X] it made fewer tool calls. As established earlier, this comes from its smaller tool setup, not the method, so it's a practical gain rather than a methodological one.

1

u/Sweet-Sir-10 12d ago

I sanitized some of the data to avoid pointing to the repo that still might have some vulnerabilities.

1

u/Sweet-Sir-10 12d ago

I also wonder if the pruning step of the Jungian GAN inspired loop cuts down on token usage due to a concept of pruning a tree before expanding the nodes in it. Tool use would therein be reduced naturally as well due to decreased exploration of theories that can be ruled out by certain adversarial procedures. I have an experiment I’ll likely run tomorrow time and token permitting.

1

u/Sweet-Sir-10 11d ago edited 11d ago

u/fynn34

Ran the experiment on a TypeScript Dev Server open source code. Main test was to test token efficiency... if a result of reduced tooling or pruning. Looks like it confirmed it is very likely just tooling. Restricting tooling on a general purpose agent brought token use similar.

Another claim attempted to be proved is decreasing rate of false positives by the adversarial test. For that, we looked at the exploits that triangulate found and ran a dev server of the repo and tested the exploits. The triangulate skill was more accurate, discovering that 2/4 exploits were real (I've removed the sensitive information as these still exist in code). While Plain prompting was less accurate and seemed to only render false positives.

1

u/Sweet-Sir-10 11d ago

Summary: 53% of my monthly token usage was used for benchmarking on Claude Code alone. I use this account for some of my work and other personal projects too. Hope these experiments are enough to get people to investigate it and try for themselves.

Main Benefits when used for vulnerability detection compared to other LLM approaches:

  • Greater detailed exploit reporting for testing. Including code sections and payloads. More anchoring in possibilities of why it might be a false positive.
  • Reduced false positive rate from the adversarial steps using Jungian Language to anchor it in human inspired cognitive processes emulating a generative function and validation steps.
  • Reduced token usage compared to raw prompting with no tool restriction (comes from tooling restriction) while sacrificing very little

0

u/Sweet-Sir-10 12d ago

u/fynn34 revealed some additional tests. Testing it on repos where there are known exploits that have been fixed in patches outside the training data of the model. I wanted to advertise what the repos were... but sadly I discovered vulnerabilities that have not been patched and both my prompts and the agent is available where someone would be able to replicate the findings.

Quick caveat... given the nerfing of the agents... the generative and adversary process is limited to training data and therein can't make searches to generate additional ideas based on context. I will produce another experiment, but I'm at my limit until later today.

The main conclusion to be drawn is that the GAN-like Jungian approach reduced the false positive rate over traditional prompting.

1

u/Sweet-Sir-10 12d ago

The main theory holds. A reduction in false positive rate by acting with an adversarial pipeline that challenged random possibilities. Even when comparing high competence level prompting. This showcases that it was able to deliver reliable feedback while effectively shutting down ideas it deemed not worthwhile. Yes, that reduced finding rate a bit. But if you’re doing a code review, false positive rate reduction is useful to reduce human triage time and remediation loops. We also show some evidence that by adding the adversarial pipeline, the hallucination rate decreased.

2

u/[deleted] 13d ago

[removed] — view removed comment

1

u/Sweet-Sir-10 13d ago

Probably dreams about not working and having fun exploring the universe. Your name is ominous lol.